#44 Regular Expression Parser

In order to be able to graph a regular expression, you first must figure out what's in it. That's the job of the parse.pm module.

The Code

 1 # 2 # parse_re -- Parse a regular expression 3 # 4 use strict; 5 use warnings; 6 7 package parse; 8 require Exporter; 9 10 use English; 11 12 use vars qw/@ISA @EXPORT/; 13 14 @ISA = qw/Exporter/; 15 @EXPORT = qw/parse_re/; 16 17 ################################################ 18 # parse_re -- Parse a regular expression 19 # and return an array of parsed data 20 ################################################ 21 sub parse_re($) 22 { 23 # The regular expression to use 24 my $quote_re = shift; 25 26 $quote_re =~ s/\\/\\\\/g; 27 28 # The command to get the debug output 29 ...

Get Wicked Cool Perl Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.