jacques has asked for the wisdom of the Perl Monks concerning the following question:

Sometimes at work I have dead time. And I look for helpful things to do. So I was wondering if anyone knew of a way to:
  1. Parse files for regular expressions
  2. Print the line number where the expression is
  3. Print what the regular expression "does" (match/substitute)
  4. Print "what" the regular expression matches or substitutes
  5. Print helpful advice on how the expression can be improved.
I guess the last one would be the most difficult to implement. Does anyone have any pointers to software that already does some of these things?

Replies are listed 'Best First'.
Re: Parser for regular expression info?
by Transient (Hermit) on May 13, 2005 at 19:48 UTC
Re: Parser for regular expression info?
by dragonchild (Archbishop) on May 13, 2005 at 19:38 UTC
    PPI. Although nothing but perl can parse Perl, PPI comes pretty darn close.

    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
Re: Parser for regular expression info?
by jhourcle (Prior) on May 13, 2005 at 20:28 UTC
    <humor mode='bad'>

    The last one's the easiest part:

    1. Take any web browser, and enter http://www.perlmonks.com
    2. Look for the link that says 'Seekers of Perl Wisdom'.
    3. Click on it.
    4. Go down to the bottom of the page.
    5. Type in what you've found in the other 4 steps.
    6. Click 'Preview'
    7. Fix any potential errors
    8. Click 'Submit', or whatever the button is called
    9. Wait

    The only problem is, you want those first 4 results first.

    </humor>