develooper 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 11, 2012 04:30
Subject:
Re: [perl #24237] @& doesn't set PL_sawampersand
Message ID:
CANgJU+Uy3_NT=DR+DAu+vZUzOvN9iyFcoLaDAtOB+kjEj5vjdQ@mail.gmail.com
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 $`
$& $'.

Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About