use List::MoreUtils qw( apply ); print OUTFILE apply { s/\s*#.*//; } grep { !/^\s*#/ } <INFILE>;
If you want to keep the lines that contained nothing but comments, remove the grep.
List::MoreUtils is not a core module, but it is a very useful module. It can be installed using ppm install List-MoreUtils if you're using ActivePerl.
In reply to Re: Regex in a printfile?
by ikegami
in thread Regex in a printfile?
by Andrew_Levenson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |