develooper Front page | perl.perl5.porters | Postings from April 2007

[perl #42363] Extra elements created in multi-dimensional arrays

Thread Next
andyt @ andy-t . org
April 9, 2007 07:42
[perl #42363] Extra elements created in multi-dimensional arrays
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #42363]
# 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.35 running under perl v5.8.7.

[Please enter your report here]

While trying to write a program that makes use of a two-dimensional
array (list of lists, to be exact), and trying to debug it, I ran into
a possible bug.  I was trying to access a non-existing element, outside
of array boundaries, and this element, as well as all intermediate
elements, were created for me.  Needless to say, they were all empty.
Here is a simple piece of code to reproduce the problem:

print $a[8][11];         # Returns empty string
print "$#a\n";           # Returns 8
print "$#{$a[8]}\n";     # Returns -1
print "$#{$a[20]}\n";    # Returns -1
print "$#a\n";           # Returns 20

This does not happen with a simple list.  Since `print' is not an 
assignment, I do not see why it should create new elements.  I wonder
if this behavior is unique to `print' function...



Dr Andy Tsouladze
Sr Unix SysAdmin
United Airlines

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

Configured by root at Wed Jul 13 12:01:19 PDT 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
    osname=linux, osvers=2.4.31, archname=i486-linux
    uname='linux midas 2.4.31 #6 sun jun 5 19:04:47 pdt 2005 i686 unknown unknown gnulinux '
    config_args='-de -Dprefix=/usr -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Doptimize=-O2 -march=i486 -mcpu=i686 -Dinc_version_list=5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 -Darchname=i486-linux'
    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=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -march=i486 -mcpu=i686',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.6', 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 -lgdbm -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='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.7:

Environment for perl v5.8.7:
    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