原文链接https://www.geeksforgeeks.org/perl-multi-line-strings-here-document/

Multiline string using Here Document

Here Document is an alternative way for multiple print statements. A Here-Document can also be used for multiline 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 users 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 "$delinn"; 
  
# 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 "$delinn"; 
  
# 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 "$delinn"; 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注