{ local $/ = "\n"; for my $line () { $line =~ s/\r?\n$//; # do your thing } }