On Wed, 12 Jun 2019 13:11:15 -0700, haukex@zero-g.net wrote: > 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' ); The magic setup code assumes it will be called separately for the array and hash (which is incorrect.) The attached fixes it (applies on top of the 131867 fix). I'll apply both in a few days unless someone sees a problem. Tony --- via perlbug: queue: perl5 status: new https://rt.perl.org/Ticket/Display.html?id=134193Thread Previous | Thread Next