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"; 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-06 13:28:06       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-06 13:28:06       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-06 13:28:06       87 阅读
  4. Python语言-面向对象

    2023-12-06 13:28:06       96 阅读

热门阅读

  1. photoshop实现抠图的步骤

    2023-12-06 13:28:06       56 阅读
  2. GNU Radio 教程

    2023-12-06 13:28:06       53 阅读
  3. 数据结构—两个有序单链表的合并排序算法

    2023-12-06 13:28:06       47 阅读
  4. 【LeetCode】203. 移除链表元素

    2023-12-06 13:28:06       56 阅读
  5. golang使用sip协议 用户名和密码注册到vos3000

    2023-12-06 13:28:06       56 阅读
  6. c#编码技巧(十五):新语法糖record深入分析

    2023-12-06 13:28:06       44 阅读