![]() |
print statement spanning multiple lines
Hi,
St00pid question time: How can I make a print statement span several lines without affecting the final formatting? I'm sure there was a 'line continuation' character of some sort which we could insert. For example, instead of having "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb bbbbbbbbbbb"; we can have print "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" LINE CONTINUE CHAR "bbbbbbbbbbbbbbbbbbbb"; I just want to get my indenting look a bit better. I can always use 2 print statements instead but do I need to? Thanks Voitec |
Re: print statement spanning multiple lines
In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>,
"Voitec" <voitec@zzzzzzzzz.com> wrote: > Hi, > > St00pid question time: there are no stupid questions, only stupid people ;-) > How can I make a print statement span several lines without affecting the > final formatting? how about: print "line 1", "line 2", "line 3"; or: print "line 1". "line 2". "line 3"; or perhaps even: print <<END; line 1 line 2 line 3 END big -- 'When I first met Katho, she had a meat cleaver in one hand and half a sheep in the other. "Come in", she says, "Hammo's not here. I hope you like meat.' Sharkey in aus.moto |
Re: print statement spanning multiple lines
Iain Chalmers wrote:
> In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>, > "Voitec" <voitec@zzzzzzzzz.com> wrote: [snip] >>How can I make a print statement span several lines without affecting the >>final formatting? > > > how about: > > print "line 1", > "line 2", > "line 3"; > > or: > > print "line 1". > "line 2". > "line 3"; Those two examples will just concatenate into one long string, not keep the indenting like the OP wanted - unless you included variables with indenting/whitespace :) Maybe something like this: print " line1 line2 line3 "; > or perhaps even: > > print <<END; > line 1 > line 2 > line 3 > END > > big > Yes :) To the OP - if you type perldoc -q "here document" from your shell, you'll the relevant details of how to correctly use a 'here' document (last example). HTH - keith |
Re: print statement spanning multiple lines
Iain Chalmers wrote: > In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>, > "Voitec" <voitec@zzzzzzzzz.com> wrote: > > >>Hi, >> >>St00pid question time: > > > there are no stupid questions, only stupid people ;-) > > >>How can I make a print statement span several lines without affecting the >>final formatting? > > > how about: > > print "line 1", > "line 2", > "line 3"; > > or: > > print "line 1". > "line 2". > "line 3"; > > or perhaps even: > > print <<END; > line 1 > line 2 > line 3 > END But this is not equivalent to the previous two! Your third version prints line1 line2 line3 while the other two print line1line2line3 (which is apparently what the OP wants). |
Re: print statement spanning multiple lines
On Tue, 11 Nov 2003 01:48:56 GMT
"Voitec" <voitec@zzzzzzzzz.com> wrote: > How can I make a print statement span several lines without > affecting the final formatting? perldoc -f format perldoc perlform HTH -- Jim Copyright notice: all code written by the author in this post is released under the GPL. http://www.gnu.org/licenses/gpl.txt for more information. a fortune quote ... Acid absorbs 47 times it's weight in excess Reality. |
Re: print statement spanning multiple lines
It was a dark and stormy night, and Voitec managed to scribble:
> Hi, > > St00pid question time: > How can I make a print statement span several lines without affecting the > final formatting? > The most obvious way us to use "\n" for newline print "line a\nline b\n\nline c"; Try 'man printf' for a list of other options (C and Perl share some libraries). gtoomey |
Re: print statement spanning multiple lines
On Tue, 11 Nov 2003, Gregory Toomey wrote:
> It was a dark and stormy night, and Voitec managed to scribble: > > > Hi, > > > > St00pid question time: > > How can I make a print statement span several lines without affecting the > > final formatting? > > > The most obvious way us to use "\n" for newline > > print "line a\nline b\n\nline c"; > > Try 'man printf' for a list of other options (C and Perl share some libraries). > > gtoomey > Are you sure you didn't misread that questions as: How can I make the final formatting span several lines without affecting the print statement? :-) Regards, Brad |
Re: print statement spanning multiple lines
On Tue, 11 Nov 2003 12:02:26 +0900, ko <kuujinbo@hotmail.com> wrote:
>Iain Chalmers wrote: >> In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>, >> "Voitec" <voitec@zzzzzzzzz.com> wrote: > >[snip] > >>>How can I make a print statement span several lines without affecting the >>>final formatting? >> >> >> how about: >> >> print "line 1", >> "line 2", >> "line 3"; >> >> or: >> >> print "line 1". >> "line 2". >> "line 3"; > >Those two examples will just concatenate into one long string, not keep >the indenting like the OP wanted - unless you included variables with >indenting/whitespace :) Maybe something like this: No, I believe the first example is what the OP wanted. He wants to indent the code, not the output. Thus; print "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbb"; would indeed seem to do the trick. Z > >print " >line1 >line2 > line3 >"; > >> or perhaps even: >> >> print <<END; >> line 1 >> line 2 >> line 3 >> END >> >> big >> > >Yes :) > >To the OP - if you type > >perldoc -q "here document" > >from your shell, you'll the relevant details of how to correctly use a >'here' document (last example). > >HTH - keith > |
Re: print statement spanning multiple lines
*snip*
> No, I believe the first example is what the OP wanted. He wants to > indent the code, not the output. > > Thus; > > print "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", > "bbbbbbbbbbbbbbbbbbbbbb"; > > would indeed seem to do the trick. > > Z Thanks. I guess I could have been a little clearer, sorry. But the intention was to indent the code not the output so the comma character is exactly what I was looking for. Thanks to all for the suggestions :c) Voitec |
Re: print statement spanning multiple lines
In article <FEisb.7553$aT.2479@news-server.bigpond.net.au>,
"Voitec" <voitec@zzzzzzzzz.com> wrote: > *snip* > > No, I believe the first example is what the OP wanted. He wants to > > indent the code, not the output. > > > > Thus; > > > > print "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", > > "bbbbbbbbbbbbbbbbbbbbbb"; > > > > would indeed seem to do the trick. > > > > Z > > Thanks. I guess I could have been a little clearer, sorry. > But the intention was to indent the code not the output so the comma > character is exactly what I was looking for. Keep in mind that while both the comma and the dot will work, they're doing slightly different things... The dot is concatenating all the separate quoted strings together into one big string then printing it, while the comma is treating each quoted string as a "list item" and joining them with the current value of $, see perldoc -f print big -- 'When I first met Katho, she had a meat cleaver in one hand and half a sheep in the other. "Come in", she says, "Hammo's not here. I hope you like meat.' Sharkey in aus.moto |
| All times are GMT. The time now is 08:48 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.