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

[perl #51688] @- array is incorrect with non matching grouping

Thread Previous | Thread Next
andrea @ inversepath . com
March 13, 2008 04:17
[perl #51688] @- array is incorrect with non matching grouping
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #51688]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.35 running under perl v5.8.8.

[Please enter your report here]

When using non matching (?: ) regular expression operator with '?' or '*'
conditionals the builtin @- array and $1, $2 matches are incorrectly set,
here's a test case:


$string = 'BDC1B1406D: to=<foo@bar>, orig_to=<bar@foo>, relay=[]:1002';

$string =~ /.*to=<(.+)>,(?: orig_to=<(.+)>,) relay=(.+)/;

print $1 . "\n";
print $2 . "\n";
print $3 . "\n";

# $1 = foo@bar, $2 = bar@foo, $3 =[]:1002

$string =~ /.*to=<(.+)>,(?: orig_to=<(.+)>,)? relay=(.+)/;

print $1 . "\n";
print $2 . "\n";
print $3 . "\n";

# $1 = bar@foo, $2 = undef, $3 =[]:1002

Clearly in this last case $1 and $2 are wrong, using (?: )* does the same.

This doesn't look like a consistent or expected behaviour to me.


[Please do not change anything below this line]
Site configuration information for perl v5.8.8:

Configured by Gentoo at Tue Nov 20 08:36:05 UTC 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
    osname=linux, osvers=2.6.20-hardened-r10, archname=i686-linux
    uname='linux fuse 2.6.20-hardened-r10 #1 fri oct 5 15:20:53 utc 2007 i686 amd sempron(tm) 2400+ authenticamd gnulinux '
    config_args='-des -Darchname=i686-linux -Dcccdlflags=-fPIC -Dccdlflags=-rdynamic -Dcc=i686-pc-linux-gnu-gcc -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth=  -Doptimize=-O2 -march=athlon-xp -fforce-addr -pipe -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/i686-linux 5.8.2 5.8.2/i686-linux 5.8.4 5.8.4/i686-linux 5.8.5 5.8.5/i686-linux 5.8.6 5.8.6/i686-linux 5.8.7 5.8.7/i686-linux  -Dcf_by=Gentoo -Ud_csh -Dusenm -Ui_ndbm -Ui_gdbm -Ui_db'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='i686-pc-linux-gnu-gcc', ccflags ='-fno-strict-aliasing -pipe -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -march=athlon-xp -fforce-addr -pipe',
    cppflags='-fno-strict-aliasing -pipe -Wdeclaration-after-statement'
    ccversion='', gccversion='3.4.6 (Gentoo Hardened 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.10)', 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='i686-pc-linux-gnu-gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lpthread -lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.8:

Environment for perl v5.8.8:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About