develooper 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 10, 2012 13:31
Subject:
[perl #24237] @& doesn't set PL_sawampersand
Message ID:
rt-3.6.HEAD-14510-1326231102-1955.24237-15-0@perl.org
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.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=24237

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