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

Re: Newlines: reading files that were created on other platforms

by adamk (Chaplain)
on Feb 02, 2005 at 06:04 UTC ( #427158=note: print w/ replies, xml ) Need Help??


in reply to Newlines: reading files that were created on other platforms

As usual, CPAN shows the way.

For about a year, I was in a situation with mixed Windows, Unix, AND Mac carriage returns, and I think I can safely say I've seen just about every screw up there is.

I evolved a regex over the years, a "universal line seperator" that handles all three newline formats, and a couple of common ugly mistakes that happen.

About a week ago, I rolled it into a CPAN module.

Go check out File::LocalizeNewlines.

It's only new, and the recursive mode might not handle binary files cleanly at this point, but all you really need is.

use File::LocalizeNewlines; File::LocalizeNewlines->localize( $filename );


Comment on Re: Newlines: reading files that were created on other platforms
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (16)
As of 2015-07-31 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls