qr//e?
Tkil
tkil-sdpm at scrye.com
Mon Apr 26 13:52:48 CDT 2004
~sdpm~
All in a quest for for a shorter way to say:
my $re = do { my $tmp = EXPR; qr/$tmp/ };
>>>>> "Alan" == Alan Stewart <alan.g.stewart at navy.mil> writes:
Alan> how about:
Alan> my $re = qr/@{[join '|', @days]}/;
Alan> from the Perl Cookbook on how to interpolate code, do anything
Alan> you want inside the @{[ ]}
Heh. I was looking for syntactic sugar, not syntactic sliced onions. :)
I started a thread on perlmonks regarding this question, and there has
been some good discussion. (And yes, the interpolate trick was
mentioned -- the only thing I'd add is a "scalar" call, as that's the
context I'd most likely want the expression in, not a list to get
squished with $".) If anyone is curious:
http://www.perlmonks.org/index.pl?node_id=347761
Thanks for the feedback here, too.
I've basically decided that /e is a bit too cute. What I really want
is the ability to apply qr// to any expression, not just a double-
quoted (or regex-double-quoted) expression. In the same way that the
functionality of \Q and \E is available outside double-quotes as
quotemeta, I would like qr to be available without double-quoting.
On the other paw, there are a fleet of workarounds, so it's not a big
deal.
t.
~sdpm~
The posting address is: san-diego-pm-list at hfb.pm.org
List requests should be sent to: majordomo at hfb.pm.org
If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:
unsubscribe san-diego-pm-list
If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.
More information about the San-Diego-pm
mailing list