in reply to Building Regex Alternations Dynamically
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Building Regex Alternations Dynamically
by haukex (Archbishop) on May 17, 2020 at 09:53 UTC |