in reply to remrem.pl - remove remarks
Some suggestions for improvement:
Having said this ... here is how I'd do it:
#!/usr/local/bin/perl -w use strict; sub usage { print << "USAGE"; 'REMoveREMarks'! remrem.pl deletes blank lines or lines starting with a '#' from a give +n file-one and prints it to STDOUT or writes it to file-two Syntax : $0 inputfile # STDOUT, try $0 inputfile | less $0 inputfile outputfile #Output to <outputfile> USAGE exit; } usage() if (!@ARGV or $ARGV[0] eq '--help'); open(FUN,"<$ARGV[0]") || die "Can't open file $ARGV[0] for reading: $! +"; if ($ARGV[1]) { open(GUN,">>$ARGV[1]") || die "Can't open file $ARGV[1] for writing: + $!" } while (<FUN>) { if (!/^#/ and /\w/) { if ($ARGV[1]) { print GUN $_; } else { print "$.: $_" } } } if ($ARGV[1]) { close(GUN) || die "Can't close file $ARGV[1]: $!" } close(FUN) || die "Can't close file $ARGV[0]: $!"
-- Hofmator
|
|---|