develooper Front page | perl.perl5.porters | Postings from August 2008

[perl #58082] Named captures don't appear in %+ when nested

Thread Next
From:
perlbug-followup
Date:
August 18, 2008 23:44
Subject:
[perl #58082] Named captures don't appear in %+ when nested
Message ID:
rt-3.6.HEAD-29762-1219081835-290.58082-75-0@perl.org
# New Ticket Created by  mjcarman@mchsi.com 
# Please include the string:  [perl #58082]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58082 >


This is a bug report for perl from mjcarman@mchsi.com,
generated with the help of perlbug 1.36 running under perl 5.10.0.

Named captures don't appear in %+ when nested inside another capture. It 
doesn't matter if the enclosing capture is named or unnamed. Curiously, 
%- does get the correct values even though %+ and %- are documented to 
be tied the same underlying hash.

[Dumper output reformatted slightly for brevity.]

use 5.010;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Indent    = 1;
$Data::Dumper::Quotekeys = 0;
$Data::Dumper::Sortkeys  = 1;

# not nested
if ('abc' =~ /(?<a>a)(?<b>b)(?<c>c)/) {
    print Data::Dumper->Dump([\%+, \%-], [qw'*+ *-']);
    print "\n\n";
}

# nested in named capture
if ('abc' =~ /(?<all>(?<a>a)(?<b>b)(?<c>c))/) {
    print Data::Dumper->Dump([\%+, \%-], [qw'*+ *-']);
    print "\n\n";
}

# nested in unnamed capture
if ('abc' =~ /((?<a>a)(?<b>b)(?<c>c))/) {
    print Data::Dumper->Dump([\%+, \%-], [qw'*+ *-']);
    print "\n\n";
}

__END__
%+ = (
  a => 'a',
  b => 'b',
  c => 'c'
);
%- = (
  a => ['a'],
  b => ['b'],
  c => ['c']
);


%+ = (
  all => 'abc'
);
%- = (
  a   => ['a'],
  all => ['abc'],
  b   => ['b'],
  c   => ['c']
);


%+ = ();
%- = (
  a => ['a'],
  b => ['b'],
  c => ['c']
);
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.10.0:

Configured by SYSTEM at Thu Jan 10 11:00:30 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -DHASATTRIBUTE -fno-strict-aliasing',
    optimize='-O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='3.4.2 (mingw-special)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-L"C:\Perl\5.10.0\lib\CORE"'
    libpth=\lib
    libs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lmsvcrt
    perllibs=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lmsvcrt
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -L"C:\Perl\5.10.0\lib\CORE"'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    32809 Load 'loadable object' with non-default file extension
    32728 64-bit fix for Time::Local

---
@INC for perl 5.10.0:
    C:/Perl/5.10.0/site/lib
    C:/Perl/5.10.0/lib
    .

---
Environment for perl 5.10.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Microsoft IntelliType Pro\;C:\Perl\5.10.0\site\bin;C:\Perl\5.10.0\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\wbem;C:\Lotus\Notes\Data;C:\Lotus\Notes;C:\Program Files\Rational\ClearCase\bin;C:\Program Files\Rational\common;C:\PROGRA~1\ATT\Graphviz\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Subversion\bin;C:\Program Files\TortoiseSVN\bin;C:\Tools;C:\MinGW\bin;Z:\FlexIO\Tools
    PERL5LIB=C:/Perl/5.10.0/site/lib
    PERL_BADLANG (unset)
    SHELL (unset)


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