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 分钟前
【项目】pyqt5基于python的照片整蛊项目
开发语言·python·qt
m0_5695310119 分钟前
shell(4)--shell脚本中的循环:(if循环,for,while,until)和退出循环(continue,break, exit)
开发语言
星释23 分钟前
Rust 练习册 :掌握文本处理与词频统计
开发语言·后端·rust
火龙谷24 分钟前
DrissionPage遇到iframe
开发语言·前端·javascript
HalvmånEver39 分钟前
Linux的第二章 : 基础的指令(二)
linux·运维·服务器·开发语言·学习
egoist20231 小时前
[linux仓库]线程同步与生产者消费者模型[线程·陆]
linux·c语言·开发语言·线程同步·阻塞队列·生产者消费者模型
资深web全栈开发3 小时前
[特殊字符]图解 Golang 反射机制:从底层原理看动态类型的秘密
开发语言·后端·golang
独隅7 小时前
在 Lua 中,你可以使用 `os.date()` 函数轻松地将时间戳转换为格式化的时间字符串
开发语言·lua
思麟呀8 小时前
Linux的基础IO流
linux·运维·服务器·开发语言·c++
星释8 小时前
Rust 练习册 :Pythagorean Triplet与数学算法
开发语言·算法·rust