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"; 
复制代码
相关推荐
Bl_a_ck33 分钟前
【React】Craco 简介
开发语言·前端·react.js·typescript·前端框架
编程有点难38 分钟前
Python训练打卡Day23
开发语言·python
程序员爱钓鱼39 分钟前
跳转语句:break、continue、goto -《Go语言实战指南》
开发语言·后端·golang·go1.19
hardStudy_h1 小时前
C程序的存储空间分配
c语言·开发语言
橙子199110161 小时前
Kotlin 中的 Unit 类型的作用以及 Java 中 Void 的区别
java·开发语言·kotlin
yours_Gabriel1 小时前
【登录认证】JWT令牌
java·开发语言·redis
lyw2056191 小时前
微服务八股(自用)
java·开发语言
dot to one1 小时前
Qt 中 QWidget涉及的常用核心属性介绍
开发语言·c++·qt
液态不合群1 小时前
理解 C# 中的各类指针
java·开发语言·c#
橙子199110161 小时前
Kotlin 中的作用域函数
android·开发语言·kotlin