in reply to Bad Regex

Here's a different sort of attack you could take on this problem, assuming that you are only looking to count comments in perl code -- it involves two steps:
  1. Use the B::Deparse module to "canonicalize" a perl script -- this includes removing all comments
  2. Find the differences between the original and deparsed versions of the script, and isolate the diffs that involve comments in the original
This could be done with the following unix-style pipeline command (and I think you should be able to see how this could be formalized as a perl script):
perl -MO=Deparse some_script.pl | diff - some_script.pl | perl -ne 'print if /^> / and /[^\$]#/'
Note that the first step only works if the script does not contain syntax errors (it has to compile properly in order to be deparsed).

Of course, this is still not perfect -- the "deparsed" output may produce a lot of minor, irrelevant differences relative to the original script, and some of these might happen to contain "#" characters that are part of the code (not commentary); also, there may still be some challenges involved with trimming the final output down to just the commentary, if that is what you want to do. But this might help to eliminate some of the complexity, and may lead to some useful ideas.

Of course, another issue is that this does not find the pod-format documentation, if any happens to exist. But to extract that, you just need to run "perldoc some_script.pl".