while () { s/\r[\n]*/\n/gm; # now, an \r (Mac) or \r\n (Win) becomes \n (UNIX) chomp $_; print STDERR "'$_'\n"; }