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

Re^2: Native newline encoding (more liberal)

by tye (Cardinal)
on May 23, 2012 at 02:52 UTC ( #971931=note: print w/ replies, xml ) Need Help??


in reply to Re: Native newline encoding
in thread Native newline encoding

s/[\r\n]+$//;

I much prefer s/\s*$//; because one should never write new code that causes trailing whitespace to be significant.

be strict in what you output  binmode  $fh, '...:crlf';

That seems like something that is quite unlikely to be what one should do. That might make sense when trying to use a Unix system to write a text file that will be used by some MS Windows program(s).

For the most common case, you should replace that 'binmode' code with this code:

- tye        


Comment on Re^2: Native newline encoding (more liberal)
Select or Download Code
Re^3: Native newline encoding (more liberal)
by Anonymous Monk on May 23, 2012 at 03:54 UTC

    That seems like something that is quite unlikely to be what one should do. That might make sense when trying to use a Unix system to write a text file that will be used by some MS Windows program(s).

    You mean like this exact situation? user wants notepad.exe to open .ini file and for it to work?

    For the most common case, you should replace that 'binmode' code with this code:

    What code?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-10-31 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (217 votes), past polls