Multiline Strings in Perl



If you want to introduce multiline strings into your programs, you can use the standard single quotes as below −

Example

 Live Demo

#!/usr/bin/perl
$string = 'This is
a multiline
string';
print "$string\n";

Output

This will produce the following result −

This is
a multiline
string

You can use "here" document syntax as well to store or print multiline as below −

Example

 Live Demo

#!/usr/bin/perl
print <<EOF;
This is
a multiline
string
EOF

Output

This will also produce the same result −

This is
a multiline
string

Advertisements