Just another Perl shrine | |
PerlMonks |
Stripping Commentsby hangon (Deacon) |
on Jun 09, 2007 at 08:43 UTC ( [id://620166]=perlquestion: print w/replies, xml ) | Need Help?? |
hangon has asked for the wisdom of the Perl Monks concerning the following question: I need to strip comments from a configuration file. The comments start with # and go to the end of the line, unless the initial # is escaped. This is what I have:
The second regex is to handle cases where the line begins with #. The third just removes the escape character. This works, but is there a better way or can it be simplified with with fewer regexes? Thanks. sample data:
desired output:
UPDATE: Got what I needed, and a little education too. Thanks for the help everyone.
Back to
Seekers of Perl Wisdom
|
|