Front page | perl.perl5.porters |
Postings from January 2012
[perl #24237] @& doesn't set PL_sawampersand
Thread Previous
|
Thread Next
From:
Father Chrysostomos via RT
Date:
January 11, 2012 08:28
Subject:
[perl #24237] @& doesn't set PL_sawampersand
Message ID:
rt-3.6.HEAD-14510-1326299295-933.24237-15-0@perl.org
On Wed Jan 11 04:32:41 2012, demerphq wrote:
> On 11 January 2012 13:30, demerphq <demerphq@gmail.com> wrote:
> > On 10 January 2012 22:31, Father Chrysostomos via RT
> > <perlbug-followup@perl.org> wrote:
> >> On Mon May 10 10:30:38 2010, chorny wrote:
> >>> Same result on 5.12.0, but I'm not sure that it is worth fixing.
> >>
> >> Fixing it is quite trivial.
> >>
> >>>
> >>> On Fri Oct 17 13:24:08 2003, grazz@pobox.com wrote:
> >>>
> >>> >
> >>> > If you use (for example) @& before using $&, then $& loses
> >>> > its magic.
> >>> >
> >>> > % perl -le '"foo" =~ /.*/; print "[$&]"'
> >>> > [foo]
> >>> >
> >>> > % perl -le '@&; "foo" =~ /.*/; print "[$&]"'
> >>> > []
> >>> >
> >>> > This worked correctly in 5.6.1 -- but of course the old behavior
> >>> > wasn't ideal either, since it set PL_sawampersand unnecessarily.
> >>> >
> >>> > http://xrl.us/xk7
> >>> >
> >>
> >> As Andreas König mentioned, it was change #11863. That’s
> b4a9608f33 in
> >> git. The commit message also refers to this thread:
> >>
>
<http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=Pine.GSO.4.21.0109031235240.7601-
> 100000@crusoe.crusoe.net>.
> >>
> >> As for fixing this: Basically we have two places in
> gv_fetchpvn_flags
> >> that add magic to stuff. The usual place, at the end of the
> function,
> >> applies when the typeglob is being created to begin with. The
> other
> >> place, further up, adds magic to things being fetched from existing
> >> typeglobs. It currently only covers %+, %-, %!, $] and @ISA (from
> >> memory, without looking).
> >>
> >> Adding $& $` $' to that section is easy. And also, the usual code
> path
> >> that sets PL_sawampersand should still magicalise $& even when
> creating
> >> the *& glob for the sake of @&.
> >>
> >> This has been done with commit a289ef89aea.
> >
> > I kinda wish this had NOT been done. It was not a true regression.
> In
> > fact arguably mentioning or using @& should not trigger
> > PL_sawampersand, which is only supposed to be triggered by use of $`
> > $& $'.
>
> On the other hand, i suppose if this is the only sane way to ensure
> the $& has the right magic then I guess it makes sense.
Did you look at the code? @& still doesn’t set PL_sawampersand, but
neither does it prevent $& from setting it any more.
And what do you mean by ‘true regression’? For $& to stop working
because some script decided to use @& seems like a regression to me.
--
Father Chrysostomos
---
via perlbug: queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=24237
Thread Previous
|
Thread Next