What I would like to do is to load a language-specific regex on demand.
Is this a decent way of doing it?
package XYZ; my %Regexes; sub regex { my $class = shift; my $lang = shift || 'en'; unless (exists $Regexes{$lang}) { my $regex_class = "${class}::$lang"; eval qq{require $regex_class}; if ($@) { die "Error loading regex for lang '$lang' : $@"; } $Regexes{$lang} = $regex_class->regex() } return $Regexes{$lang} } package main; my $regex = XYZ->regex('en')
In reply to Loading a language specific regex on demand by clinton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |