in reply to Re^2: How the perl converts LF into CRLF
in thread How the perl converts LF into CRLF
#!/usr/bin/perl -w use strict; use File::Temp qw(tempfile); use File::Copy; dos_to_unix($ARGV[1]); sub dos_to_unix { my($file) = @_; my($dst, $src); my (undef, $tmpfile) = tempfile(); copy($file, $tmpfile) or die "Can't copy $file to $tmpfile due to: $!\n"; open($dst, ">$file") or die "Can't open $file for write due to: $!\n"; open($src, "<$tmpfile") or die "Can't open $tmpfile for read due to: $!\n"; binmode($dst); while(<$src>) { chomp; print $dst "$_\n"; } close($dst); close($src); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How the perl converts LF into CRLF
by Anonymous Monk on Jul 03, 2009 at 09:27 UTC |