Subject: | _regexp is useful, should be renamed and documented |
I use Regexp::Trie for fast scan of words, but as I need
case-insensitive matches, I use the internal undocumented _regexp()
method, instead of regexp().
The following code:
use Regexp::Trie;
my $rt = Regexp::Trie->new;
for (qw/foobar fooxar foozap fooza/){
$rt->add($_);
}
print $rt->regexp, "\n";
print $rt->_regexp, "\n";
Prints:
(?-xism:foo(?:bar|xar|zap?))
foo(?:bar|xar|zap?)
The problem with regexp() is the "(?-i:" case sensitive flag.
What I do in my code is:
$re = $rt->_regexp;
/$re/i;
but I feel guilty of using an internal method.
Suggestion: rename _regexp to regexp_string
Best regards
Paulo Custodio