$file=''; open(IN,"<$filename") || die "$file can't be opened: $!"; { local $/=undef; $file=; } ($\) = (/(\r\n|\r|\n)/); # make output rec-separator same as input @lines=split /[\r\n]+/, $file; foreach $line (@lines) { # do some processing here }