afshinbozorg has asked for the wisdom of the Perl Monks concerning the following question:
but the file I am writing to is coming with ^M char ?s/\015\012/\012/g s/\015/\013/\013/g s/\r\n/\n/g
#! perl -w # Convert a dos format file to Unix removing ^M Char from file my $FileOpen = $ARGV[0]; my $FileTemp = "$FileOpen.Temp9687"; open(OPEN,"$FileOpen") || die "\nCan not open file $FileOpen $!\n"; open(CONV,">$FileTemp") || die "\nCan not write to file $FileTemp $!\n +"; foreach(<OPEN>){ $_ =~ s/\r\n/n/g; # $_ =~ s/\015\012/\012/g; # $_ =~ s/\015\013/\013/g; # $_ =~ s/\015//g; print CONV $_; } close(OPEN); close(CONV);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing ^M char AKA dos2unix
by BrowserUk (Patriarch) on Feb 25, 2010 at 21:57 UTC | |
by jdrago999 (Pilgrim) on Feb 27, 2010 at 00:01 UTC | |
by Anonymous Monk on Feb 27, 2010 at 00:17 UTC | |
|
Re: Removing ^M char AKA dos2unix
by jwkrahn (Abbot) on Feb 25, 2010 at 21:49 UTC | |
|
Re: Removing ^M char AKA dos2unix
by astroboy (Chaplain) on Feb 26, 2010 at 02:23 UTC | |
|
Re: Removing ^M char AKA dos2unix
by Anonymous Monk on Feb 25, 2010 at 22:42 UTC | |
|
Re: Removing ^M char AKA dos2unix
by jdrago999 (Pilgrim) on Feb 26, 2010 at 20:14 UTC | |
by afshinbozorg (Initiate) on Mar 03, 2010 at 14:52 UTC |