debugging - a strategy for dealing with uncompilable regexps
debugging file-of-patterns
prints out the version of script.
By default, Regexp::Assemble uses a naive strategy for chopping up input. It can get upset if you try to feed it a pattern with nested parentheses. For instance, a(b(c)) and a(b(d)) will cause it to fail. If you really want to do that, you'll have to come up with a regexp that can chop the above into a, (b(c)) and a, (b(d)).
Regexp::Assemble
a(b(c))
a(b(d))
a
(b(c))
(b(d))
Of course, that will only buy you a(?:(b(c))|(b(d))) at the present time. Teaching it to produce a(b([cd])) would be considerably more complex. Patches welcome.
a(?:(b(c))|(b(d)))
a(b([cd]))
So, when adding hundreds of patterns, it's not always obvious figuring out a way of isolating the offending pattern, especially when they are coming out of a file or some other process you don't have control over.
The trick, then, consists of adding a pattern one at a time, and then standing back and watching whether producing a regexp from the list of patterns seen so far will cause things to blow up. So you take a copy of the assembly, and add the pattern to the copy. If that works, then add it to the real assembly. Repeat until done.
You don't want to do this all the time, because it is of course much less efficient.
Copyright (C) 2005 David Landgren. All rights reserved.
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Regexp::Assemble, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::Assemble
CPAN shell
perl -MCPAN -e shell install Regexp::Assemble
For more information on module installation, please visit the detailed CPAN module installation guide.