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]."
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.