Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Here documents in blocks [chomp]

by kcott (Archbishop)
on Dec 20, 2020 at 03:57 UTC ( [id://11125483]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found