in reply to @- Bug on the loose, lets isolate it

I quote from perlvar
"@- $-[0] is the offset of the start of the last successful match. "$-["n"]" is the offset of the start of the substring matched by n-th subpattern, or undef if the subpattern did not match."

So, in my understanding you really wanted to print $-[0] isn't it? You may run this:
use strict; use warnings; my $string = "abc"; while( $string =~ /c/g ) { print "$-[0]\n"; }
and get "2", and:
use strict; use warnings; my $string = "abc"; while( $string =~ /c/g ) { print "@-\n"; }
I get:
Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. Use of uninitialized value in join or string at /tmp/bug1.pl line 7. 2

perl version:
Summary of my perl5 (revision 5 version 8 subversion 5) configuration: Platform: osname=linux, osvers=2.6.9, archname=i686-linux-thread-multi uname='linux gnistorica 2.6.9 #1 mon nov 29 11:26:11 eet 2004 i686 + intel(r) pentium(r) 4 cpu 2.80ghz genuineintel gnulinux ' config_args='-des -Darchname=i686-linux-thread -Dcccdlflags=-fPIC +-Dccdlflags=-rdynamic -Dcc=gcc -Dprefix=/usr -Dvendorprefix=/usr -Dsi +teprefix=/usr -Dlocincpth= -Doptimize=-O3 -mcpu=i686 -fomit-frame-po +inter -pipe -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin -Dm +an1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman +1dir=/usr/share/man/man1 -Dinstallman3dir=/var/tmp/portage/perl-5.8.5 +-r5/image//usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dinc_version +_list=5.8.0 5.8.0/i686-linux-thread-multi 5.8.2 5.8.2/i686-linux-thre +ad-multi 5.8.4 5.8.4/i686-linux-thread-multi -Dcf_by=Gentoo -Ud_csh +-Dusethreads -Di_ndbm -Di_gdbm -Di_db' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS + -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=6 +4', optimize='-O3 -mcpu=i686 -fomit-frame-pointer -pipe', cppflags='-DPERL5 -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS - +fno-strict-aliasing -pipe' ccversion='', gccversion='3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2 +-3, pie-8.7.7.1)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lpthread -lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -l +c perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.3.4.so, so=so, useshrplib=false, libperl=libperl. +a gnulibc_version='2.3.4' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_CONTEXT Built under linux Compiled at Mar 15 2005 11:11:33 @INC: /etc/perl /usr/lib/perl5/site_perl/5.8.5/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i686-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.5/i686-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/local/lib/site_perl /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi
Dodge This!

Replies are listed 'Best First'.
Re^2: @- Bug on the loose, lets isolate it
by thor (Priest) on May 30, 2005 at 16:17 UTC
    I think the point is not what the @- array contains, but that it contains anything at all. The supplied regex doesn't do any capturing, so the @- array should be empty. What we're seeing is that perl is creating a very large array for no reason. Doing so takes time, thus slowing down programs where it shouldn't. That's a Bad Thing.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Good point :-)
      Dodge This!
      Both @- and @+ should contain at least one element each to show where the start and end of the match is. You're supposed to be able to derive $& from substr( ..., $-[0], $+[0] - $-[0] ).