develooper Front page | perl.perl5.porters | Postings from June 2019

[perl #134193] Accessing @{^CAPTURE} before %{^CAPTURE} empties thelatter

Thread Previous
From:
Hauke D
Date:
June 12, 2019 20:11
Subject:
[perl #134193] Accessing @{^CAPTURE} before %{^CAPTURE} empties thelatter
Message ID:
rt-4.0.24-11876-1560370275-1343.134193-75-0@perl.org
# New Ticket Created by  Hauke D 
# Please include the string:  [perl #134193]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=134193 >


Hi all,

As reported by vr on PerlMonks 
(https://www.perlmonks.org/?node_id=11101258), accessing @{^CAPTURE} 
before %{^CAPTURE} causes the latter to become an empty, untied hash.


$ perl -MData::Dumper -e '"a"=~/(?<X>a)/; print Dumper \%{^CAPTURE}, 
\@{^CAPTURE}, tied(%{^CAPTURE})'
$VAR1 = {
           'X' => 'a'
         };
$VAR2 = [
           'a'
         ];
$VAR3 = bless( do{\(my $o = 256)}, 'Tie::Hash::NamedCapture' );


$ perl -MData::Dumper -e '"a"=~/(?<X>a)/; print Dumper \@{^CAPTURE}, 
\%{^CAPTURE}, tied(%{^CAPTURE})'
$VAR1 = [
           'a'
         ];
$VAR2 = {};
$VAR3 = undef;


$ perl -v
This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux
...


The output I would expect from the second example is:
$VAR1 = [
           'a'
         ];
$VAR2 = {
           'X' => 'a'
         };
$VAR3 = bless( do{\(my $o = 256)}, 'Tie::Hash::NamedCapture' );


Thanks, Regards,
-- Hauke D


Thread Previous


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