1GraphViz::Regex(3)    User Contributed Perl Documentation   GraphViz::Regex(3)
2
3
4

NAME

6       GraphViz::Regex - Visualise a regular expression
7

SYNOPSIS

9         use GraphViz::Regex;
10
11         my $regex = '(([abcd0-9])⎪(foo))';
12
13         my $graph = GraphViz::Regex->new($regex);
14         print $graph->as_png;
15

DESCRIPTION

17       This module attempts to visualise a Perl regular expression. Under‐
18       standing regular expressions is tricky at the best of times, and
19       regexess almost always evolve in ways unforseen at the start. This mod‐
20       ule aims to visualise a regex as a graph in order to make the structure
21       clear and aid in understanding the regex.
22
23       The graph visualises how the Perl regular expression engine attempts to
24       match the regex. Simple text matches or character classes are repre‐
25       sented by.box-shaped nodes. Alternations are represented by a diamond-
26       shaped node which points to the alternations. Repetitions are repre‐
27       sented by self-edges with a label of the repetition type (the nodes
28       being repeated are pointed to be a full edge, a dotted edge points to
29       what to match after the repetition). Matched patterns (such as $1, $2,
30       etc.) are represented by a 'START $1' .. 'END $1' node pair.
31
32       This uses the GraphViz module to draw the graph.
33

METHODS

35       new
36
37       This is the constructor. It takes one mandatory argument, which is a
38       string of the regular expression to be visualised. A GraphViz object is
39       returned.
40
41         my $graph = GraphViz::Regex->new($regex);
42
43       as_*
44
45       The regex can be visualised in a number of different graphical formats.
46       Methods include as_ps, as_hpgl, as_pcl, as_mif, as_pic, as_gd, as_gd2,
47       as_gif, as_jpeg, as_png, as_wbmp, as_ismap, as_imap, as_vrml, as_vtx,
48       as_mp, as_fig, as_svg. See the GraphViz documentation for more informa‐
49       tion. The two most common methods are:
50
51         # Print out a PNG-format file
52         print $g->as_png;
53
54         # Print out a PostScript-format file
55         print $g->as_ps;
56

BUGS

58       Note that this module relies on debugging information provided by Perl,
59       and is known to fail on at least two versions of Perl: 5.005_03 and
60       5.7.1. Sorry about that - please use a more recent version of Perl if
61       you want to use this module.
62

AUTHOR

64       Leon Brocard <acme@astray.com>
65
67       Copyright (C) 2000-1, Leon Brocard
68
69       This module is free software; you can redistribute it or modify it
70       under the same terms as Perl itself.
71
72
73
74perl v5.8.8                       2004-12-02                GraphViz::Regex(3)
Impressum