develooper Front page | perl.perl5.porters | Postings from November 2011

[perl #104182] The "exists" function changes the hash structure

Thread Next
From:
jor @ looney . jax . org
Date:
November 21, 2011 05:46
Subject:
[perl #104182] The "exists" function changes the hash structure
Message ID:
rt-3.6.HEAD-5084-1321879216-507.104182-75-0@perl.org
# New Ticket Created by  jor@looney.jax.org 
# Please include the string:  [perl #104182]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=104182 >



This is a bug report for perl from jim.richardson@jax.org,
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------
[Please enter your report here]

I use the "exists" function to determine the presence of keys within
the Hash.  I offer use effectively multi-dimensioned hashes for example
"$hash{key1}{key2}".  If I want to check if key2 is present under key1 I
tried using the statement "exists $hash{key1}{key2}" which returns a
false (zero).  The problem is, if key1 didn't exists in the hash the 
"exists" statement creates the key in the hash, which changes the data.
I would think the exists would first check the presence of key1 and if
it doesn't exists the stop checking and return a false (zero).

Jim Richardson

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.1:

Configured by jor at Tue Jan 29 12:54:54 EST 2002.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos looney 5.8 generic_108528-12 sun4u sparc sunw,ultra-5_10 '
    config_args='-de'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='3.0.2', gccosandvers='solaris2.8'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.1:
    /usr/jax/depot/perl-5.6.1/lib/5.6.1/sun4-solaris
    /usr/jax/depot/perl-5.6.1/lib/5.6.1
    /usr/jax/depot/perl-5.6.1/lib/site_perl/5.6.1/sun4-solaris
    /usr/jax/depot/perl-5.6.1/lib/site_perl/5.6.1
    /usr/jax/depot/perl-5.6.1/lib/site_perl
    .

---
Environment for perl v5.6.1:
    HOME=/home/jor
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/lib:/etc/lib:/etc/security/lib:/opt/SUNWits/Graphics-sw/xil/lib:/usr/ccs/lib:/usr/dt/appconfig/dtpower/lib:/usr/dt/appconfig/netscape/j2pi/lib:/usr/dt/appconfig/netscape/lib:/usr/dt/appconfig/sdtaudiocontrol/lib:/usr/dt/appconfig/sdtpdasync/lib:/usr/dt/appconfig/sdtprodreg/lib:/usr/dt/lib:/usr/j2se/jre/lib:/usr/j2se/lib:/usr/java1.2/jre/lib:/usr/jax/lib:/usr/lib/help/lib:/usr/local/lib:/usr/openwin/lib:/usr/openwin/platform/sun4u/server/lib:/usr/openwin/server/lib:/usr/platform/sun4u/lib:/usr/sadm/admin/printmgr/lib:/usr/sadm/lib:/usr/sadm/lib/smc/lib:/usr/sadm/smc/lib:/usr/share/lib:/usr/snadm/lib:/usr/vmsys/lib:/usr/xpg4/lib:/var/sadm/smc/lib
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/jax/bin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin:/usr/ucb:/home/jor/bin:/group/sysad/cs/bin:/group/cs/cs/bin:/usr/sbin:/opt/SUNWrtvc/bin:/sbin:/usr/apache/bin:/usr/dt/bin:/usr/java/bin:/usr/lib/lp/bin:/usr/oasys/bin:/usr/perl5/5.00503/bin:/usr/platform/sun4u/sbin:/usr/proc/bin:/usr/sadm/admin/bin:/usr/sadm/bin:/usr/sadm/install/bin:/usr/sadm/lib/smc/bin:/usr/sadm/sysadm/bin:/usr/snadm/bin:/usr/vmsys/bin:/usr/xpg4/bin:/usr/unsupported/bin:.
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About