It took some time until I discovered this jewel. It's great. Thanks a lot!
One thought about the usage of map: Here it needs to be in list context, which is a bit odd when declaring a scalar. In a version that has two characters more to type this can be avoided:
my $regex = sub { qr/@_/ }->( join '|', map {quotemeta} sort { length $b <=> length $a } @values); print "$regex\n";
Greetings,
-jo
In reply to Re: Building Regex Alternations Dynamically
by jo37
in thread Building Regex Alternations Dynamically
by haukex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |