> This sounds pretty strange,
> like a misunderstanding of
> some essential concepts of Perl.
> If not, could you show us a working example,
> and a copy of perl -V that exhibits that problem?
#!/usr/bin/perl -w
use strict;
my %results = (
'results' => [
[10, 13, 14]
],
);
# Add array reference to integer number without a warning,
# result is a big number, 10896017 on my architecture
print 1 + $results{'results'}->[0], "\n";
# print number of elements in array + 1
print 1 + scalar(@{$results{'results'}->[0]}), "\n";
# forgot @{, produces big number (10896017)
# very easy to do mistake
# can lead to hours of bughunting
print 1 + scalar($results{'results'}->[0]), "\n";
Not sure why `perl -V` is needed but here it is:
par@maxlance ~/projects $ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.31-gentoo-r6, archname=x86_64-linux-threa
+d-multi
uname='linux maxlance.homelinux.org 2.6.31-gentoo-r6 #9 smp wed de
+c 23 03:27:57 msk 2009 x86_64 amd athlon(tm) 64 x2 dual core processo
+r 5400+ authenticamd gnulinux '
config_args='-des -Darchname=x86_64-linux-thread -Dcccdlflags=-fPI
+C -Dccdlflags=-rdynamic -Dcc=x86_64-pc-linux-gnu-gcc -Dprefix=/usr -D
+vendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth= -Doptimize=-O2 -pip
+e -march=athlon64 -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/b
+in -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinst
+allman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -
+Dman1ext=1 -Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/x86_64-linux-
+thread-multi 5.8.2 5.8.2/x86_64-linux-thread-multi 5.8.4 5.8.4/x86_64
+-linux-thread-multi 5.8.5 5.8.5/x86_64-linux-thread-multi 5.8.6 5.8.6
+/x86_64-linux-thread-multi 5.8.7 5.8.7/x86_64-linux-thread-multi -Dc
+f_by=Gentoo -Ud_csh -Dusenm -Dusethreads -Di_ndbm -Di_gdbm -Di_db -Du
+srinc=/usr/include -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64'
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=define use64bitall=define uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='x86_64-pc-linux-gnu-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
+ -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-s
+tatement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gd
+bm',
optimize='-O2 -pipe -march=athlon64',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-stri
+ct-aliasing -pipe -Wdeclaration-after-statement -I/usr/include/gdbm'
ccversion='', gccversion='4.3.4', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1
+6
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
+ lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='x86_64-pc-linux-gnu-gcc -O2 -pipe -march=athlon64', ldflags ='
+ -L/usr/local/lib64'
libpth=/usr/local/lib64 /lib64 /usr/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.9'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami
+c'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_64_BIT_
+ALL
USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Jan 14 2010 11:10:33
@INC:
/etc/perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib64/perl5/vendor_perl/5.8.8
/usr/lib64/perl5/vendor_perl
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib64/perl5/site_perl/5.8.8
/usr/lib64/perl5/site_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
/usr/lib64/perl5/5.8.8
/usr/local/lib/site_perl
.
par@maxlance ~/projects $
|