Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: breaking a line on printing

by abaxaba (Hermit)
on Mar 19, 2002 at 17:12 UTC ( [id://152782]=note: print w/replies, xml ) Need Help??


in reply to breaking a line on printing

There have been some good suggestions here, but no one has mentioned my particular favorite, which I use especially with html output.
I push everything onto an array, then just dump the array. This seems to work for me for a couple of reasons:
1. Format whitespace, easier readability.
2. Pass array ref around to different subs, to build up output string in a modular format, without worrying about return values:
#!perl main(); sub main { my @output; push (@output, "Here is something to print out\n", "Here is yet another line\n"); extra(\@output); print @output; } sub extra { my $resRef = shift; push (@$resRef, "Here is an extra line\n"); } exit 0;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-19 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found