in reply to Can't get rid of \r
I would handle this as follows:
This code should work on both Unix and Windows.open(my $in, "<", $inputfile) or die "Can't read '$inputfile': $!"; open(my $out, "<", $outputfile) or die "Can't read '$outputfile': $!"; binmode($out); while (my $line = <$in>) { $line =~ s/\r\n?/\n/g; print $out $line; } close($in) or die "Can't close '$inputfile': $!"; close($out) or die "Can't close '$outputfile': $!";
I actually leave out the closes usually. Putting them in will tell you if, for instance, you had a full disk. But I usually don't worry about that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't get rid of \r
by rovf (Priest) on Sep 12, 2008 at 08:42 UTC |