while (my $line = <$in>) { $line =~ s/\n/\r/; # replace LF with CR in the line print $out $line; # and output it }