Front page | perl.perl5.porters |
Postings from January 2012
Re: [perl #24237] @& doesn't set PL_sawampersand
Thread Previous
|
Thread Next
From:
demerphq
Date:
January 12, 2012 04:03
Subject:
Re: [perl #24237] @& doesn't set PL_sawampersand
Message ID:
CANgJU+X2qHR4WLycJG0ukrAtVUMcL4cr4vQSn8CTUwiUoP7YDw@mail.gmail.com
On 11 January 2012 17:28, Father Chrysostomos via RT
<perlbug-followup@perl.org> wrote:
> 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.
I was hasty in my original response. Sorry.
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
Thread Previous
|
Thread Next