Front page | perl.perl5.porters |
Postings from April 2003
Range operator misbehaving
Thread Next
From:
Dan Brook
Date:
April 3, 2003 06:30
Subject:
Range operator misbehaving
Message ID:
20030403153026.3451f2e1.dbrook@easyspace.com
When the range operator is used on it's own within in a list that the
reference operator is working on it returns an array reference (as
opposed to a list of references). However B::Deparse produces the
*expected* output
$localhost.dan(1.221, "bleadperl") perl5.6.1 -MO=Deparse -le '$x = \(1
.. 5); print "\$x($x): @$x"'
$x = \(1, 2, 3, 4, 5);
print "\$x($x): @$x";
-e syntax OK
$localhost.dan(1.222, "bleadperl") perl5.8.0 -MO=Deparse -le '$x = \(1
.. 5); print "\$x($x): @$x"' BEGIN { $/ = "\n"; $\ = "\n"; }
$x = \(1, 2, 3, 4, 5);
print "\$x($x): @$x";
-e syntax OK
$localhost.dan(1.223, "bleadperl") ./perl -Ilib -MO=Deparse -le '$x =
\(1 .. 5); print "\$x($x): @$x"' BEGIN { $/ = "\n"; $\ = "\n"; }
$x = \(1, 2, 3, 4, 5);
print "\$x($x): @$x";
-e syntax OK
Which is expected behaviour, however the output is quite different
$localhost.dan(1.218, "bleadperl") perl5.6.1 -le '$x = \(1 .. 5); print
"\$x($x): @$x"'$x(ARRAY(0x8107ff4)): 1 2 3 4 5
$localhost.dan(1.219, "bleadperl") perl5.8.0 -le '$x = \(1 .. 5); print
"\$x($x): @$x"'$x(ARRAY(0x8061528)): 1 2 3 4 5
$localhost.dan(1.220, "bleadperl") ./perl -le '$x = \(1 .. 5); print
"\$x($x): @$x"'$x(ARRAY(0x8129570)): 1 2 3 4 5
But when the operator is 'forced' into list context it behaves as
expected
$localhost.dan(1.210, "bleadperl") perl5.6.1 -le '$x = \(1 .. 5,6);
print @$x' Not an ARRAY reference at -e line 1.
$localhost.dan(1.211, "bleadperl") perl5.8.0 -le '$x = \(1 .. 5,6);
print @$x' Not an ARRAY reference at -e line 1.
$localhost.dan(1.212, "bleadperl") ./perl -le '$x = \(1 .. 5,6); print
@$x' Not an ARRAY reference at -e line 1.
And the version details ...
$localhost.dan(1.229, "bleadperl") perl5.6.1 -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.17-0.13smp, archname=i386-linux
uname='linux daffy.perf.redhat.com 2.4.17-0.13smp #1 smp fri feb 1
10:30:48 est 2002 i686 unknown ' config_args='-des -Doptimize=-O2
-march=i386 -mcpu=i686 -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dcccdlflags=-fPIC
-Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr -Uusethreads -Uuseithreads
-Uuselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm
-Di_shadow -Di_syslog -Dman3ext=3pm' hint=recommended, useposix=true,
d_sigaction=define usethreads=undef use5005threads=undef
useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef
uselargefiles=undef usesocks=undef use64bitint=undef
use64bitall=undef uselongdouble=undef Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include',
optimize='-O2 -march=i386 -mcpu=i686',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.2
2.96-109)', 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=4 alignbytes=4,
usemymalloc=n, prototype=define Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.so, 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'
Characteristics of this binary (from libperl):
Compile-time options:
Built under linux
Compiled at Apr 1 2002 12:23:22
@INC:
/usr/lib/perl5/5.6.1/i386-linux
/usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/5.6.1/i386-linux
/usr/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.6.1/i386-linux
/usr/lib/perl5/vendor_perl/5.6.1
/usr/lib/perl5/vendor_perl
.
$localhost.dan(1.230, "bleadperl") perl5.8.0 -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.18-3, archname=i686-linux-thread-multi
uname='linux dhcp152.noc.easyspace.net 2.4.18-3 #1 thu apr 18
07:37:53 edt 2002 i686 unknown ' config_args='-Dusethreads'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define useperlio=define d_sfio=undef
uselargefiles=define usesocks=undef use64bitint=undef
use64bitall=undef uselongdouble=undef usemymalloc=n,
bincompat5005=undef Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm', optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-I/usr/local/include -I/usr/include/gdbm' ccversion='',
gccversion='2.96 20000731 (Red Hat Linux 7.3 2.96-110)', 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 =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/usr/local/lib/perl5/5.8.0/i686-linux-thread-multi/CORE'
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 Oct 17 2002 13:52:58
@INC:
/usr/local/lib/perl5/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl
/home/dan/.perl
/root/.perl
.
$localhost.dan(1.232, "bleadperl") ./perl -Ilib -V
Summary of my perl5 (revision 5.0 version 9 subversion 0 patch 19143)
configuration: Platform:
osname=linux, osvers=2.4.18-3, archname=i686-linux
uname='linux dhcp140.noc.easyspace.net 2.4.18-3 #1 thu apr 18
07:37:53 edt 2002 i686 unknown ' config_args='-d'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef 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 -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2', cppflags='-fno-strict-aliasing -I/usr/local/include
-I/usr/include/gdbm' ccversion='', gccversion='2.96 20000731 (Red Hat
Linux 7.3 2.96-110)', 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 =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil -lrt
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil -lrt
libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Locally applied patches:
DEVEL18374
Built under linux
Compiled at Apr 3 2003 14:04:04
@INC:
lib
/usr/local/lib/perl5/5.9.0/i686-linux
/usr/local/lib/perl5/5.9.0
/usr/local/lib/perl5/site_perl/5.9.0/i686-linux
/usr/local/lib/perl5/site_perl/5.9.0
/usr/local/lib/perl5/site_perl
.
Dan
Thread Next
-
Range operator misbehaving
by Dan Brook