Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Formatting Strings Without Interpolating Whitespace

by JavaFan (Canon)
on Jan 19, 2012 at 22:27 UTC ( #948860=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Formatting Strings Without Interpolating Whitespace
in thread Formatting Strings Without Interpolating Whitespace

Just do exactly what I said, don't include the newlines you don't want:

my $msg_body_1 = "line 1\n" . "line 2\n" . "line3a \t \line3b\n" . "line4" . "\n\n" ;


Comment on Re^3: Formatting Strings Without Interpolating Whitespace
Download Code
Re^4: Formatting Strings Without Interpolating Whitespace (join)
by tye (Cardinal) on Jan 19, 2012 at 23:14 UTC

    Having worked on a lot of code that did such things, I found that I had much fewer regrets with the almost subtly different:

    my $msg_body_1 = join '', "line 1\n", "line 2\n", "line3a \t \line3b\n", "line4", "\n\n", ;

    '.' binds tighter than a lot of things that are pretty common to include in a list of things to be joined together. The "no trailing '.' allowed" problem (an endless source of pain for me outside of Perl but in the form of "no trailing comma allowed") goes away when using comma.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-07-11 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls