Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Difference between using \r\n and \n on Linux and Windows machines

by bart (Canon)
on Jun 09, 2005 at 06:55 UTC ( [id://464984]=note: print w/replies, xml ) Need Help??


in reply to Difference between using \r\n and \n on Linux and Windows machines

Use the same version as on Linux, on Windows. The output layer for the file handle FH will, when in text mode (i.e. when binmode hasn't been used on it, like here) convert every "\n" character to the CR+LF sequence — or, like you typed, "\r\n", at least on Windows and Linux, as this notation isn't very portable.

So, if you insert a "\r" character yourself, you will end up with two because perl inserts one itself next to the "\n". So don't do that.

p.s. If you want to create a Unix text file on Windows, you can do

binmode FH;
before you print anything to it, and this conversion is prevented, you'll get an identical result on Windows as on Linux.
  • Comment on Re: Difference between using \r\n and \n on Linux and Windows machines
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-19 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found