N
nitroamos
hello -- i've been spending quite a bit of time trying to figure out
this issue, and now that i've found a workaround, i'm wondering if the
problem was a bug. basically, i have some code that looks like this:
$orbitals[$i] =~ /\s+(\d)\s+Orbital Energy/;
$index = $1;
$index--; $index++;
if($element =~ /_${index}_/ or $element =~ m/_$index$/){
print "$element matches $& with index = $index\n";
}
this is just a small part of my program, so i hope i've shown enough to
isolate the bug. Basically, I'm trying to grab an integer out of a
string, and then look in another string to see if i have a match. i've
pasted what the output looks like at the bottom. as you can see, the
incorrect results are producing a subset of the matches I expect --
only the first pattern on the if line is matching.
for some reason, without the $index--; $index++; business, my second
pattern is not matching. after fooling around, it seems that somehow
it's entirely related to the $ anchor. although not what I want, if I
add a ^ anchor i can get matches with or without the $ anchor. so
somehow the $ anchor all by itself is not working unless i do the --/++
business.
what kind of weirdness is this? i've pasted perl -V at the bottom. if
this is some version specific bug, then that's all i need to know; i'm
ok with the workaround. but if there's something that i'm not
understanding, then i want to know what i'm missing.
thanks!
results where everything is working as expected (correctly):
_1 matches _1 with index = 1
_2 matches _2 with index = 2
_3 matches _3 with index = 3
_4 matches _4 with index = 4
_5 matches _5 with index = 5
_1_2 matches _1_ with index = 1
_1_2 matches _2 with index = 2
_1_3 matches _1_ with index = 1
_1_3 matches _3 with index = 3
_2_3 matches _2_ with index = 2
_2_3 matches _3 with index = 3
_1_4 matches _1_ with index = 1
_1_4 matches _4 with index = 4
_2_4 matches _2_ with index = 2
_2_4 matches _4 with index = 4
_3_4 matches _3_ with index = 3
_3_4 matches _4 with index = 4
_1_5 matches _1_ with index = 1
_1_5 matches _5 with index = 5
_2_5 matches _2_ with index = 2
_2_5 matches _5 with index = 5
_3_5 matches _3_ with index = 3
_3_5 matches _5 with index = 5
_4_5 matches _4_ with index = 4
_4_5 matches _5 with index = 5
results where the "$index--; $index++;" line has been commented out
(incorrect results):
_1_2 matches _1_ with index = 1
_1_3 matches _1_ with index = 1
_2_3 matches _2_ with index = 2
_1_4 matches _1_ with index = 1
_2_4 matches _2_ with index = 2
_3_4 matches _3_ with index = 3
_1_5 matches _1_ with index = 1
_2_5 matches _2_ with index = 2
_3_5 matches _3_ with index = 3
_4_5 matches _4_ with index = 4
here is what perl -V says:
Summary of my perl5 (revision 5.0 version 8 subversion 0)
configuration:
Platform:
osname=linux, osvers=2.4.21-1.1931.2.382.entsmp,
archname=i386-linux-thread-multi
uname='linux str'
config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686
-Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red
Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr
-Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
-Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
-isr'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef'
useithreads=define usemultiplicity=
useperlio= d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=un uselongdouble=
usemymalloc=, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)',
gccosandvers=''
gccversion='3.2.2 200302'
intsize=r, longsize=r, ptrsize=5, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long'
k', ivsize=4'
ivtype='l, nvtype='double'
o_nonbl', nvsize=, Off_t='', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc'
l', ldflags =' -L/u'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libper
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef,
ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC'
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s
Unicode/Normalize XS/A'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Locally applied patches:
MAINT18379
Built under linux
Compiled at Aug 13 2003 11:47:58
@INC:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
this issue, and now that i've found a workaround, i'm wondering if the
problem was a bug. basically, i have some code that looks like this:
$orbitals[$i] =~ /\s+(\d)\s+Orbital Energy/;
$index = $1;
$index--; $index++;
if($element =~ /_${index}_/ or $element =~ m/_$index$/){
print "$element matches $& with index = $index\n";
}
this is just a small part of my program, so i hope i've shown enough to
isolate the bug. Basically, I'm trying to grab an integer out of a
string, and then look in another string to see if i have a match. i've
pasted what the output looks like at the bottom. as you can see, the
incorrect results are producing a subset of the matches I expect --
only the first pattern on the if line is matching.
for some reason, without the $index--; $index++; business, my second
pattern is not matching. after fooling around, it seems that somehow
it's entirely related to the $ anchor. although not what I want, if I
add a ^ anchor i can get matches with or without the $ anchor. so
somehow the $ anchor all by itself is not working unless i do the --/++
business.
what kind of weirdness is this? i've pasted perl -V at the bottom. if
this is some version specific bug, then that's all i need to know; i'm
ok with the workaround. but if there's something that i'm not
understanding, then i want to know what i'm missing.
thanks!
results where everything is working as expected (correctly):
_1 matches _1 with index = 1
_2 matches _2 with index = 2
_3 matches _3 with index = 3
_4 matches _4 with index = 4
_5 matches _5 with index = 5
_1_2 matches _1_ with index = 1
_1_2 matches _2 with index = 2
_1_3 matches _1_ with index = 1
_1_3 matches _3 with index = 3
_2_3 matches _2_ with index = 2
_2_3 matches _3 with index = 3
_1_4 matches _1_ with index = 1
_1_4 matches _4 with index = 4
_2_4 matches _2_ with index = 2
_2_4 matches _4 with index = 4
_3_4 matches _3_ with index = 3
_3_4 matches _4 with index = 4
_1_5 matches _1_ with index = 1
_1_5 matches _5 with index = 5
_2_5 matches _2_ with index = 2
_2_5 matches _5 with index = 5
_3_5 matches _3_ with index = 3
_3_5 matches _5 with index = 5
_4_5 matches _4_ with index = 4
_4_5 matches _5 with index = 5
results where the "$index--; $index++;" line has been commented out
(incorrect results):
_1_2 matches _1_ with index = 1
_1_3 matches _1_ with index = 1
_2_3 matches _2_ with index = 2
_1_4 matches _1_ with index = 1
_2_4 matches _2_ with index = 2
_3_4 matches _3_ with index = 3
_1_5 matches _1_ with index = 1
_2_5 matches _2_ with index = 2
_3_5 matches _3_ with index = 3
_4_5 matches _4_ with index = 4
here is what perl -V says:
Summary of my perl5 (revision 5.0 version 8 subversion 0)
configuration:
Platform:
osname=linux, osvers=2.4.21-1.1931.2.382.entsmp,
archname=i386-linux-thread-multi
uname='linux str'
config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686
-Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red
Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr
-Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
-Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
-isr'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef'
useithreads=define usemultiplicity=
useperlio= d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=un uselongdouble=
usemymalloc=, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)',
gccosandvers=''
gccversion='3.2.2 200302'
intsize=r, longsize=r, ptrsize=5, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long'
k', ivsize=4'
ivtype='l, nvtype='double'
o_nonbl', nvsize=, Off_t='', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc'
l', ldflags =' -L/u'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libper
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef,
ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC'
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s
Unicode/Normalize XS/A'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Locally applied patches:
MAINT18379
Built under linux
Compiled at Aug 13 2003 11:47:58
@INC:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0