P is for Practical | |
PerlMonks |
Re: heredoc and carriers returnby LanX (Saint) |
on Oct 25, 2016 at 13:47 UTC ( [id://1174692]=note: print w/replies, xml ) | Need Help?? |
> heredoc read the LF ( \n ) , but dont parse / stores the carriers return ( \r ) there is a misconception on your side and probably it's an XY Problem too. \n is the newline according to the OS you use and NOT (only) the LF from ASCII. When you print "some line break \n and more lines" then Perl will autotranslate the \n to whatever *nix, win or mac wants to see. Perl does it to assure maximum OS independency. You are probably bitten by the reverse effect, that some combinations of CR and LF are interpreted as \n. The answer to your problem is asking what for do you need it? If you just need linebreaks ignore the effect, if you need the \r otherwise, do like suggested and include them explicitly. You are free to put the text into an external file and read it in binmode , or even encode it as hex or base64 if you really need literally the same ascii code.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|