in reply to Use function as a regex
How about just Re::re($str) instead? Or maybe $str =~ /$Re::h{re}/g
Without the /g you would have been able to use $str =~ Re::re(). But to have the global search I can only think of $str =~ /@{[ Re::re() ]}/g or /(??{ Re::re() })/g which aren't much of an improvement.
Can your subs have parameters? If there is one regex for each sub, where the name of the sub is also the key in the hash, you maybe be interested in AUTOLOAD.
Edit: choroba made me realize it's (??{ }) not (?{{ }}) (which should have been obvious, as the latter is actually a case of (?{ }))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use function as a regex
by stevieb (Canon) on Feb 15, 2018 at 16:39 UTC | |
|
Re^2: Use function as a regex
by Anonymous Monk on Feb 15, 2018 at 16:50 UTC | |
by Eily (Monsignor) on Feb 15, 2018 at 17:17 UTC | |
by Anonymous Monk on Feb 15, 2018 at 18:29 UTC |