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"; 
复制代码
相关推荐
会飞De琥珀16 分钟前
java工具类,字符串转时间
java·开发语言
源码潇潇和逸逸30 分钟前
独立部署高校圈子平台:PHP+UniApp打造社交+交易+服务一站式校园解决方案
开发语言·uni-app·php
LINgZone239 分钟前
深入解析:Cglib与JDK动态代理的实现原理、区别及性能对比
java·开发语言
一次旅行39 分钟前
今日心理学知识分享(三)
开发语言·javascript·程序人生·ecmascript
AI科技星1 小时前
光速螺旋量子几何统一场论——基于 v ≡ c 公理的四大基本力全维度求导证明与精准数值验证
c语言·开发语言·人工智能·算法·机器学习·平面
天天学IT1 小时前
第三章 Qt 编译及安装
开发语言·qt·qt教程·qt6教程
xyq20241 小时前
Window Memcached 安装指南
开发语言
牛十二1 小时前
openclaw安装mcporter搜索小红书
开发语言·javascript·ecmascript
老刘说AI1 小时前
WorkFlow Agent案例:auto_document_agent(文件自动处理)
开发语言·数据库·人工智能·python·神经网络·自然语言处理
时寒的笔记1 小时前
js逆向05_ob混淆花指令,平坦流,某麦网(突破ob混淆寻找拦截器)
开发语言·前端·javascript