|GraphViz::Regex(3)||User Contributed Perl Documentation||GraphViz::Regex(3)|
use GraphViz::Regex; my $regex = '(([abcd0-9])|(foo))'; my $graph = GraphViz::Regex->new($regex); print $graph->as_png;
The graph visualises how the Perl regular expression engine attempts to match the regex. Simple text matches or character classes are represented by.box-shaped nodes. Alternations are represented by a diamond-shaped node which points to the alternations. Repetitions are represented by self-edges with a label of the repetition type (the nodes being repeated are pointed to be a full edge, a dotted edge points to what to match after the repetition). Matched patterns (such as $1, $2, etc.) are represented by a 'START $1' .. 'END $1' node pair.
This uses the GraphViz module to draw the graph.
my $graph = GraphViz::Regex->new($regex);
# Print out a PNG-format file print $g->as_png; # Print out a PostScript-format file print $g->as_ps;
This module is free software; you can redistribute it or modify it under the Perl License, a copy of which is available at http://dev.perl.org/licenses/.