develooper Front page | perl.perl5.porters | Postings from July 2001

[ID 20010731.072] map vs array of hashes with holes

Thread Next
From:
Ric Anderson
Date:
July 31, 2001 13:10
Subject:
[ID 20010731.072] map vs array of hashes with holes
Message ID:
200107312009.f6VK9nE21282@sylvester.Telcom.Arizona.EDU
This is a bug report for perl from staff@ms.telcom.arizona.edu,
generated with the help of perlbug 1.26 running under perl 5.00503.


-----------------------------------------------------------------
[Please enter your report here]
--begin test program--
use strict;
my(@port,$port,$mac);
$port[0]->{port_mac} = 47;
$port[0]->{port} = 147;
$port[1]->{port_mac} = 48;
$port[1]->{port} = 148;
$port[3]->{port_mac} = 56;
$port[3]->{port} = 156;
print "port array = ", join(",",@port), "\n";
$mac = 1;
map {if ($_->{port_mac} eq $mac) {$port = ($_->{port})}} @port;
$port = "not found" if(!defined($port));
print "port = $port.\n";
--end test program--
If one saves the above to poo, and runs
	perl poo
one gets
  Modification of a read-only value attempted at poo.tc line 11.
It appers that map() doesn't like a sparse array of hashes.  I'm
not sure if this a bug, or a restriction that isn't apparent
to me from the documentation.

[Please do not change anything below this line]
-----------------------------------------------------------------

---
Site configuration information for perl 5.00503:

Configured by ric at Mon Aug  7 13:59:26 MST 2000.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos coyote.telcom.arizona.edu 5.6 generic_105181-16 sun4u sparc sunw,ultra-enterprise '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc -B/usr/ccs/bin/', optimize='-O', gccversion=egcs-2.91.66 19990314 (egcs-1.1.2 release)
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc -B/usr/ccs/bin/', ldflags ='-L/usr/local/lib -R/usr/local/lib'
    libpth=/usr/local/lib /usr/ccs/lib /usr/openwin/lib /usr/dt/lib /usr/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    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 -R/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.00503:
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .

---
Environment for perl 5.00503:
    HOME=/home/ric
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ric/bin/sparc:/home/ric/bin/Scripts:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/local/bin:/usr/proc/bin
    PERL_BADLANG (unset)
    SHELL=/bin/ksh


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