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"; 
复制代码
相关推荐
小杍随笔几秒前
【Rust桌面革命:Tauri×Dioxus——架构对决、实战拆解与2026选型杀招】
开发语言·架构·rust
计算机安禾2 分钟前
【c++面向对象编程】第4篇:类与对象(三):拷贝构造函数与深浅拷贝问题
开发语言·c++·算法
j_xxx404_4 分钟前
Linux共享内存原理与实战:从内核到C++实现|附源码
linux·运维·开发语言·c++·人工智能
金玉满堂@bj14 分钟前
Python 后端开发 从零到就业完整教程(2026 企业级完整版)
开发语言·python
qq_2698704321 分钟前
claude code 终端安装
开发语言
XiYang-DING23 分钟前
【Java】URL(Uniform Resource Locator)
java·开发语言
0xDevNull24 分钟前
Java十道高频面试题
java·开发语言
Brilliantwxx25 分钟前
【算法题】递归树+哈希表+分治异或+双指针
开发语言·c++·笔记·算法
yugi98783825 分钟前
经典三维表面重建算法(C语言实现)
c语言·开发语言·算法
Hello:CodeWorld26 分钟前
高性能多线程数据采集与持久化方案设计与实现
开发语言·c++