Perl | Multi-line Strings | Here Document

原文链接:https://www.geeksforgeeks.org/perl-multi-line-strings-here-document/

Multi-line string using Here Document

Here Document is an alternative way for multiple print statements. A Here-Document can also be used for multi-line string. It declares a delimiter at the start to know till where the string needs to take input. A Here-Document starts with '<<' followed by the delimiter of the user's choice. The string reads the code until the delimiter occurs again and all the text in between is taken as the string.

Example:

```c

```c
# Perl code to illustrate the multiline  
# string using Here-Document 
  
# consider a string scalar 
$GeeksforGeeks = 'GFG'; 
  
# defining multiline string using  
# ending delimiter without any quotes 
$deli = <<string_ending_delimiter; 
  
Multiline string using  
      
     Here-Document on  
      
    $GeeksforGeeks
  
string_ending_delimiter 
  
# displaying result  
print "$deli\n\n"; 
  
# defining multiline string using  
# ending delimiter with double quotes 
$deli = <<"string_ending_delimiter"; 
  
Multiline string using  
      
     Here-Document on  
      
    $GeeksforGeeks
  
string_ending_delimiter 
  
# displaying result  
print "$deli\n\n"; 
  
# defining multiline string using  
# ending delimiter with single quotes 
$deli = <<'string_ending_delimiter'; 
  
Multiline string using  
      
     Here-Document on  
      
    $GeeksforGeeks
  
string_ending_delimiter 
  
# displaying result  
print "$deli\n\n"; 
复制代码
相关推荐
姝孟14 分钟前
C++——类和对象
开发语言·c++
小白学大数据14 分钟前
Snapchat API 访问:Objective-C 实现示例
开发语言·macos·objective-c
gopher951115 分钟前
go语言基础入门(一)
开发语言·golang
masa01021 分钟前
JavaScript--JavaScript基础
开发语言·javascript
拓端研究室TRL24 分钟前
Python用TOPSIS熵权法重构粮食系统及期刊指标权重多属性决策MCDM研究|附数据代码...
开发语言·python·重构
一只特立独行的猪6111 小时前
Java面试——集合篇
java·开发语言·面试
大得3692 小时前
go注册中心Eureka,注册到线上和线下,都可以访问
开发语言·eureka·golang
小珑也要变强3 小时前
队列基础概念
c语言·开发语言·数据结构·物联网
AI原吾6 小时前
掌握Python-uinput:打造你的输入设备控制大师
开发语言·python·apython-uinput
机器视觉知识推荐、就业指导6 小时前
Qt/C++事件过滤器与控件响应重写的使用、场景的不同
开发语言·数据库·c++·qt