http://www.perlmonks.org?node_id=103284


in reply to Quick and portable way to determine line-ending string?

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.