Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^5: heredoc and carriers return

by pryrt (Monsignor)
on Oct 25, 2016 at 23:24 UTC ( #1174746=note: print w/replies, xml ) Need Help??

in reply to Re^4: heredoc and carriers return
in thread heredoc and Carriage return

Read, and Super Search for __DATA__ to find more details.

In short, you add __DATA__ as a line by itself at the end of your script, and everything after that in your script is treated as a special file which you can access through the handle DATA; like STDIN and STDOUT, it's already available, and you don't even have to open(DATA, ...) yourself. To get it to do what you want (maintain the distinct CR and LF from the Win32 EOL), you will need to binmode DATA; before you read from the DATA filehandle, just like you would if it were an external file.

__DATA__ is pretty cool. Make sure you read up on it -- there are lots of cool __DATA__ tricks lurking in the Monastery.

Replies are listed 'Best First'.
Re^6: heredoc and carriers return
by LanX (Sage) on Oct 26, 2016 at 07:36 UTC
    He already got a sample for __DATA__ in his reddit crosspost ... :/

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      it works !!!

      thanks a lot @pryrt and @LanX

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2021-10-27 18:03 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (94 votes). Check out past polls.