use warnings; use strict; open my $fh, '<', 'foo.txt' or die $!; binmode $fh; $/="\x0D"; while (<$fh>) { chomp; ... } close $fh;