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"; 
复制代码
相关推荐
listhi52018 分钟前
基于改进SET的时频分析MATLAB实现
开发语言·算法·matlab
友友马1 小时前
『QT』事件处理机制详解 (一)
开发语言·qt
孤独斗士1 小时前
maven的pom文件总结
java·开发语言
confiself1 小时前
通义灵码分析ms-swift框架中CHORD算法实现
开发语言·算法·swift
1024小神1 小时前
在 Swift 中,self. 的使用遵循明确的规则
开发语言·ios·swift
Swift社区1 小时前
Swift 类型系统升级:当协议遇上不可拷贝的类型
开发语言·ios·swift
chengpei1471 小时前
I²C协议简介
c语言·开发语言
唐古乌梁海1 小时前
【IT】常见计算机编程语言多继承问题
开发语言
雨中散步撒哈拉1 小时前
18、做中学 | 初升高 | 考场一 | 面向过程-家庭收支记账软件
开发语言·后端·golang
翔云 OCR API2 小时前
承兑汇票识别接口技术解析-开发者接口
开发语言·前端·数据库·人工智能·ocr