it is awful to read huge config files full with remarks.
remrem.pl removes all remarks and blank lines to concentrate config files to the essence. it has two output possiblities and even more using the shell.
(updated 20010914, using HERE documents, the rest I left in peace for your convenience to see the differences to Hofmators way.)
#!/usr/local/bin/perl -w
sub usage {
print <<EOF;
'REMoveREMarks'!
remrem.pl deletes blank lines or lines starting with a '#' from a giv
+en file-one
and prints it to STDOUT or writes it to file-two
Syntax :
$0 inputfile
# STOUT, try $0 inputfile | less
$0 inputfile outputfile
#Output tho <outputfile>
EOF
}
if (
(! $ARGV[0] ) or
( $ARGV[0] eq "--help")
) {
usage;
exit;
}
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"
}
foreach $zeile (<FUN>) {
$zaehler++;
if (
( ! ($zeile=~/^(#+)/ ) ) and
( $zeile=~/\w/)
) {
if ($ARGV[1]) {
print GUN $zeile
}
else {
print "$zaehler: $zeile"
}
}
}
if ($ARGV[1]) {
close(GUN)||die "Can't close filehandle $ARGV[1]."
}
close(FUN)||die "Can't close filehandle $ARGV[0]."