Dealing with EOL chars

Alex Brelsfoard alex.brelsfoard at
Wed Jan 23 23:28:45 GMT 2008

Hi all,

Sorry for making such an on-topic post, but seeing as this is my first post
with I figured I might pretend to be Perl-centric.

I am currently trying to work on a system that reads in all kinds of feeds.
These feeds can be created on a PC, new/old mac, or a *nix machine.
And I need to be able to deal with them all.
Here's the kicker, these feeds sometimes have inline breaks, and we need to
keep them.

Does anyone have any suggestions on how to deal with this?

This works:
my $newline = "\n";
my $file = '788_test.txt';
open (my $file_fh, $file) || die "could not open $file for reading";
my $file_content = <$file_fh>;
$file_content =~ s/(?:\015{1,2}\012|\015|\012)/$newline/sg;
foreach (split(/\n/, $file_content)) {
print "$_\n";

I can even split on that regular expression and save a line of code.
But I'm just concerned about losing inline breaks.



More information about the mailing list