Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: 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
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!


In reply to Re: heredoc and carriers return by LanX
in thread heredoc and Carriage return by gabrielsousa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2021-10-26 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?