in reply to Re: Re: Good Idiom for Matching List?
in thread Good Idiom for Matching List?
That is, the first result is the argument to the second line, and is not used for anything else.my $x= f(); $x= g($x);
So I would naturally write it as my $x=g(f()); instead, as one expression without a named temporary.
Here's the rub: qr// does not use the normal function syntax. It uses the quoting syntax, which doesn't naturally handle arbitrary nesting. So, use the @{[]} hack (or worse, if the list context would be a problem) or use Interpolation to work-around.
But what I really want is a callable function that takes a string and returns the corresponding compiled regex. We have quotemeta and lc that let us access special syntax features in a normal functional way; I want that for everything.
—Johnsub mk_qr ($) { eval "qr/$_[0]/"; }
|
|---|