in reply to Bad Regex
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).perl -MO=Deparse some_script.pl | diff - some_script.pl | perl -ne 'print if /^> / and /[^\$]#/'
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".
|
|---|