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

Is there perhaps a CPAN module or some other technique to get a report of how a regex is trying to match as it matches? Maybe something like:

Trying to match atom '\d+'... matched with '83'. Trying to match atom 'text'... failed at position 20, next character i +s 'h'. etc..
I'm thinking along the lines of what you get from Parse::RecDescent with $RD_TRACE set.

kelan


Perl6 Grammar Student

update (broquaint): s{<(/)?pre>}{<${1}code>}g

Replies are listed 'Best First'.
Re: Watching a regex match
by Enlil (Parson) on Mar 17, 2003 at 16:15 UTC
    You could put use re 'debug'; at the top of your script.

    -enlil

      Ah, thank you. This is exactly what I was looking for. :)

      kelan


      Perl6 Grammar Student

Re: Watching a regex match
by larsen (Parson) on Mar 17, 2003 at 16:16 UTC
Re: Watching a regex match
by meetraz (Hermit) on Mar 17, 2003 at 16:53 UTC
    One of my favorite tools for doing regex debugging is Komodo's Regex Toolkit (pic here). Basically, you put in your regex & the input data, and then you can step through the matches. It even shows $1,$2,etc... worth checking out.