The stupid question is the question not asked | |
PerlMonks |
Re: qr// with /e?by Anomynous Monk (Scribe) |
on Apr 25, 2004 at 04:59 UTC ( [id://347926]=note: print w/replies, xml ) | Need Help?? |
I can think of a couple ways to do that now:
$re = qr/${\do{join '|', @days}}/
(as you would interpolate any expression in to any double-quotish construct), or
$re = qr/(??{join '|', @days})/
which only evaluates the code when the regex is actually
executing (and indeed may evaluate it more than once if
backtracked over).
Both forms may have problems with finding the end of the code given e.g. an unmatched } within the code; the latter currently has unfortunate interaction with lexical vars.
In Section
Seekers of Perl Wisdom
|
|