develooper Front page | perl.perl5.porters | Postings from February 2004

[perl #26986] $& value does not properly propagate into replacement body of s///

Thread Next
February 23, 2004 19:10
[perl #26986] $& value does not properly propagate into replacement body of s///
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #26986]
# 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.34 running under perl v5.8.2.

[Please enter your report here]

perl -wle '@F="A".."BZ"; $_="a"; s/./<$F[@a="b"..$&]>/; print; print"a=@a"'
Argument "b" isn't numeric in range (or flop) at -e line 1.
Use of uninitialized value in range (or flop) at -e line 1.
Use of uninitialized value in range (or flop) at -e line 1.

I expected $& to be "a", so @a should become (a b c ....z), so fetch 
element 26 from @F, which should be "Z"

The 'Argument "b" isn't numeric in range (or flop) at -e line 1.' seems to
indicate $& is undef which in my perl still causes @a to become (0)
(this was bug 24735, but even with that fixed I just expect that now
@a will be () and it will output <A>, which is still wrong).

However, mentioning $& in the real string body will make things work 
as expected:
perl -wle '@F="A".."BZ"; $_="a"; s/./$&<$F[@a="b"..$&]>/; print; print"a=@a"'
a=b c d e f g h i j k l m n o p q r s t u v w x y z

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

Configured by ton at Sun Jan  4 19:19:06 CET 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
    osname=linux, osvers=2.6.0, archname=i686-linux-64int-ld
    uname='linux quasar 2.6.0 #3 thu dec 18 18:22:48 cet 2003 i686 gnulinux '
    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=define use64bitall=undef uselongdouble=define
    usemymalloc=y, bincompat5005=undef
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -fomit-frame-pointer',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.4.0 20031231 (experimental)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-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.2:

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

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