Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Native newline encoding (more liberal)

by tye (Sage)
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        

Replies are listed 'Best First'.
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?
[atcroft]: stevieb: I have berrybrew installed on a Win machine, and I noticed that with perlbrew you can "upgrade" a particular installed version... any chance of doing something similar in the
[atcroft]: future with berrybrew?
[atcroft]: stevieb: Also, one other odd question... is it possible to set it up so that all the versions installed can use a single directory that they pull module sources into, rather than duplicating files? (Am I making sense, or do I have too high a CBC
[atcroft]: (caffeine-blood content) atm?)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-04-29 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.