in reply to Here documents in blocks

Here's another trick I've used occasionally that involves chomp.

The following code will leave a blank line at the end of <pre> blocks when the HTML is rendered:

$ perl -e ' my $insert = <<EOF; line1 line2 line3 EOF print "<pre>$insert</pre>"; ' <pre>line1 line2 line3 </pre>

chomp to the rescue:

$ perl -e ' chomp(my $insert = <<EOF); line1 line2 line3 EOF print "<pre>$insert</pre>"; ' <pre>line1 line2 line3</pre>

It can fix lots of annoying problems like that; not just <pre> blocks.

— Ken