in reply to Re: Re: strip perl comment lines
in thread strip perl comment lines

On the off chance that you aren't merely kidding around and haven't looked at the module in question, I feel compelled to point out a couple of things. Not only does Regexp::Common's Perl comment matcher (which is essentially this re: /#[^\n]*\n/) suffer from the various problems listed previously, but your example use also doesn't come close to what epoptai was originally trying to do (which was to just strip lines beginning with optional whitespace and a # character, with the exception of the shebang line). Your example of:

s/$RE{comment}{Perl}//;

would delete *any* # character (comment or not) to the end of a line (including the newline character) and turn the following code:

#!/usr/bin/perl -w use strict; $_ = "blah # blah"; s#blah #boog#gx; print;

into:

use strict; $_ = "blah s print;

Which is useful only useful insofar as it demonstrates the problems inherent with simple attempts to strip Perl comments.