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"; 
复制代码
相关推荐
去往火星几秒前
C++(Qt)软件调试---binutils工具集详解
开发语言·c++
赶飞机偏偏下雨25 分钟前
【Java笔记】消息队列
java·开发语言·笔记
00后程序员张27 分钟前
C++ string 类使用攻略
开发语言·c++
融化的雪38 分钟前
reactflow整理节点,尾节点位置的大坑
开发语言·前端·javascript
豐儀麟阁贵1 小时前
2.6 代码注释与编码规
java·开发语言
egoist20231 小时前
[linux仓库]信号保存[进程信号·肆]
linux·开发语言·信号集·信号保存·sigpending
你不是我我1 小时前
【Java 开发日记】什么是线程池?它的工作原理?
java·开发语言
成子不是橙子1 小时前
Langchain | Ollama | Python快速上手使用LLM的DEMO
开发语言·python·langchain·ollama
梵得儿SHI1 小时前
Java 反射机制深度解析:从运行时 “解剖” 类的底层逻辑
java·开发语言·反射·反射机制·private·类成员·反射的三大核心功能
虚行2 小时前
Python学习入门
开发语言·python·学习