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