Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jarthur!kfink From: kfink@jarthur.Claremont.EDU (Kevin Fink) Newsgroups: comp.lang.perl Subject: Question about dbm files and assoc arrays Message-ID: <8133@jarthur.Claremont.EDU> Date: 17 Aug 90 15:38:19 GMT Organization: Harvey Mudd College, Claremont, CA 91711 Lines: 71 When I upgraded from pl 18 to pl 28, one of my scripts broke. I'm not sure if the problem is in the patches or in a change in our system, however. The problem arises when using the dbm functions. The op.dbm test works, but this script doesn't do what I think it should... #! /usr/local/binperl $test = "test"; dbmopen(TEST,$test,0666); dbmopen(TEST2,$test,0666) || die "ndbm missing"; dbmclose(TEST2); @keylist = keys(%TEST); @vallist = values(%TEST); while ($#keylist ne -1) { $key = pop(@keylist); $val = pop(@vallist); printf "%s\t%s\n",$key,$val; } print "1 : ".$TEST{'hello'}."\n"; print "2 : ".$TEST{$key}."\n"; $TEST{'hello'} = "hi"; print "3 : ".$TEST{'hello'}."\n"; dbmclose(TEST); dbmopen(TEST1,$test,0666); print "4 : ".$TEST1{'hello'}."\n"; dbmclose(TEST1); When this script is run, I would expect to get 1 : 2 : 3 : hi 4 : hi since TEST doesn't contain anything until I assign hi to hello. When I run it a second time (once the dbm file has been saved to disk) I would expect to get hello hi 1 : hi 2 : hi 3 : hi 4 : hi However, what I actually get the first time is 1 : 2 : 3 : hi 4 : and the second time I get hello hi 1 : 2 : 3 : hi 4 : So it appears that the assoc array is saved to the dbm file, but either I'm making a dumb mistake trying to get the value of hello out, or something is broken. I'm running perl pl 28 on a Sequent Balance running Dynix 3.0.17.9. Thanks. Kevin Fink kfink@jarthur.claremont.edu