There's more than one way to do things | |
PerlMonks |
Re: Quick and portable way to determine line-ending string?by mdillon (Priest) |
on Aug 09, 2001 at 03:34 UTC ( [id://103284]=note: print w/replies, xml ) | Need Help?? |
can't you split on the value of $/? (whose value is presumably related to $^O in the Perl source code and hence will always be in synch): my @lines = split m#$/#, $content;or how about just splitting on any line ending?: my @lines = split m#\x0d\x0a?|\x0a#, $content;to get around the multiple 0x0d problem, you could add \x0d+\x0a to the alternation as the first alternative (though it will slow things down on a Unix file with a lot of blank lines). come to think of it, \x0d{2}\x0a might be a better idea. for EBCDIC, i think the first solution i mentioned should work. for some reason, i feel like i'm missing something fundamental about your question, so if i'm just spouting crazy-talk, please ignore me.
In Section
Seekers of Perl Wisdom
|
|