Front page | perl.perl5.porters |
Postings from September 2011
[perl #98352] Postponed code subregex *can* see capture groups
Thread Next
From:
Peter Scott
Date:
September 3, 2011 20:12
Subject:
[perl #98352] Postponed code subregex *can* see capture groups
Message ID:
rt-3.6.HEAD-31297-1315061262-1269.98352-75-0@perl.org
# New Ticket Created by Peter Scott
# Please include the string: [perl #98352]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=98352 >
perlre says:
"(??{ code })"
[...]
The result of evaluation is considered a regular expression and
matched as if it were inserted instead of this construct. Note
that this means that the contents of capture groups defined
inside
an eval'ed pattern are not available outside of the pattern, and
vice versa, there is no way for the inner pattern to refer to a
capture group defined outside. Thus,
('a' x 100)=~/(??{'(.)' x 100})/
will match, it will not set $1.
The last assertion is true, however, the one before it appears not to be:
% perl -E '"abc" =~ /(.)(??{say "\$1=$1"; "(.)"})/ and say "\$2=$2"'
$1=a
$2=
In other words, the subexpression *can* access capture groups defined
outside itself. Either the documentation or the code should be changed.
Summary of my perl5 (revision 5 version 15 subversion 2) configuration:
Commit id: a438ddfd375bdc676cbf6945958c7a4250fc24f4
Platform:
osname=linux, osvers=2.6.27.24-170.2.68.fc10.i686, archname=i686-linux
uname='linux tweety.homeip.net 2.6.27.24-170.2.68.fc10.i686 #1 smp
wed may 20 23:10:16 edt 2009 i686 i686 i386 gnulinux '
config_args='-des -Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.3.2 20081105 (Red Hat 4.3.2-7)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.9'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PERL_USE_DEVEL
USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO
USE_PERL_ATOF
Built under linux
Compiled at Aug 26 2011 11:18:09
%ENV:
PERLBREW_PATH="/home/peter/perl5/perlbrew/bin"
PERLBREW_ROOT="/home/peter/perl5/perlbrew"
PERLBREW_VERSION="0.25"
@INC:
lib
/usr/local/lib/perl5/site_perl/5.15.2/i686-linux
/usr/local/lib/perl5/site_perl/5.15.2
/usr/local/lib/perl5/5.15.2/i686-linux
/usr/local/lib/perl5/5.15.2
/usr/local/lib/perl5/site_perl
.
Thread Next