qr//e?
Tkil
tkil-sdpm at scrye.com
Fri Apr 23 17:06:31 CDT 2004
~sdpm~
>>>>> "Chris" == Chris Radcliff <chris_radcliff at mac.com> writes:
Chris> I couldn't articulate why it's a Good Idea, but /e only applies
Chris> to the right side of a substitution.
Right; I'm proposing a change to the language.
Chris> In your case, are you hoping to re-evaluate the join() each
Chris> time you use the compiled expression (e.g. if @days were to
Chris> change for some reason)?
No. I want the /e to take place exactly once: eval the contents of
the qr//, then apply qr to that result (returning the compiled regex
object.) Maybe some bastard hybrid of "/oe" is really what I'm
looking for...
I really intend for these two statements to have the same result:
my $re = qr/EXPR/e;
my $re = do { my $tmp = eval { EXPR } ; qr/$tmp/ };
Chris> If not, why not just do this:
Chris> my $days = join '|', @days;
Chris> my $days_re = qr/$days/;
Because this leaves $days in scope for no good reason (that's why I
used the "do" block in the first place). The "do BLOCK" approach has
exactly the semantics I want; I just wanted it to be shorter and
sweeter.
I suppose I should have simply asked if people thought that /e was a
worthwhile shorthand, or if (as your response seems to indicate) it
would confuse people into think it applied every time the qr object
was used.
Chris> Cheers,
Chris> ~chris (off the top of me 'ead)
Thanks for the feedback, anyway! :)
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