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"; 
复制代码
相关推荐
sinat_6020353614 分钟前
模块与包的导入
运维·服务器·开发语言·python
恋雨QAQ16 分钟前
python函数和面向对象
开发语言·python
天雪浪子34 分钟前
Python入门教程之逻辑运算符
开发语言·python
落羽的落羽1 小时前
【C++】特别的程序错误处理方式——异常机制
开发语言·c++
通达的K1 小时前
Java实战项目演示代码及流的使用
java·开发语言·windows
云:鸢1 小时前
C语言链表设计及应用
c语言·开发语言·数据结构·链表
离越词2 小时前
C++day8作业
开发语言·c++·windows
℃CCCC2 小时前
请求库-axios
开发语言·华为·网络请求·harmonyos·deveco studio·axios请求·arkts编程
ling__i3 小时前
java day18
java·开发语言