in reply to Re: Good Idiom for Matching List?
in thread Good Idiom for Matching List?
Or, if I were golfing:my $goodnames = qr/@{[join '|', map "\Q$_", sort @names]}/;
my $goodnames = qr/@{[join'|',map"\Q$_",sort@names]}/; ;-)
And, if I were going to be interpolating arrays into regexes on a regular basis, I'd probably modularize the process thus:
use Interpolation OR => sub { join '|', map "\Q$_", sort @{$_[0]} }; # and later... my $goodnames = qr/$OR{\@names}/;
BTW, arrays will interpolate disjunctively in Perl 6, so eventually you'll be able to just write:
# Perl 6 code my $goodnames = /@names/;
Yet another feature for Abigail to not be impressed by, I guess. ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Good Idiom for Matching List?
by John M. Dlugosz (Monsignor) on Dec 11, 2002 at 21:05 UTC | |
|
typo or more changes coming our way?
by John M. Dlugosz (Monsignor) on Dec 11, 2002 at 21:13 UTC | |
by theorbtwo (Prior) on Dec 11, 2002 at 21:56 UTC |