Category: | Utility Scripts |
Author/Contact Info | Stephen JamesAckohno@mail.ru |
Description: | This is a little script i came up with to get those ^M's out of files that come in the downloaded source here at PerlMonks. Given one argument (a file name), the script removes the ^M's from that file; given two, the first is input and second is output. If the if statment matching for the perl shebang is removed, this script can be used to remove the ^M's from any file. Without that if statment, there may be a new line at the begining of the file witch will cause the script not to run. |
#!/usr/bin/perl -w use strict; my $out; if(@ARGV!=1 && @ARGV!=2){ print "Usage:\n\t$0 input [output];\n"; exit; } open(IN, "<$ARGV[0]") or die "couldn't open $ARGV[0]: $!"; if(<IN>=~m/(^#!.*perl.*)/){ $out.=$1; } while(<IN>){ chomp; chop; $_.="\n"; $out.=$_; } close IN; if(@ARGV==1){ unlink $ARGV[0]; open(OUT,">$ARGV[0]") or die "couldn't open $ARGV[0]: $!"; } elsif(@ARGV==2){ open(OUT,">$ARGV[1]") or die "couldn't open $ARGV[1]: $!"; } print OUT $out; close OUT; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: win2unix
by atcroft (Abbot) on Jul 20, 2002 at 08:08 UTC | |
by ackohno (Scribe) on Jul 20, 2002 at 08:15 UTC | |
Re: win2unix
by Ionitor (Scribe) on Jul 20, 2002 at 17:33 UTC | |
by ackohno (Scribe) on Jul 21, 2002 at 04:25 UTC | |
Re: win2unix
by Courage (Parson) on Jul 20, 2002 at 08:33 UTC | |
by Anonymous Monk on Jul 21, 2002 at 03:16 UTC | |
| |
by ackohno (Scribe) on Jul 20, 2002 at 16:33 UTC |
Back to
Code Catacombs