in reply to assign a string using multiline format
being equivalent to "$var" where $var contains everything between the first line and the last line.<<END; sometext more END
It is interpolated, so any vars inside the HEREDOC is also expanded. So
$foo = 'danmcb'; print <<END; $foo was here and here END # will print danmcb was here and here
Most wherever you can use $var, you can usually use the HEREDOC. For example
my $text = $cgi->param('text') || <<END; some text passed via the cgi END
works very well. Keep in mind, the trailing END has to be flush with the left most column.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: assign a string using multiline format
by reasonablekeith (Deacon) on Aug 26, 2005 at 12:55 UTC | |
by danmcb (Monk) on Aug 26, 2005 at 13:17 UTC | |
by Taulmarill (Deacon) on Aug 26, 2005 at 13:28 UTC | |
by chibiryuu (Beadle) on Aug 26, 2005 at 14:54 UTC |