[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] (de)referencing and DBM files



Howdy all,

How does one go about dereferencing an array stored as a value in a DBM
hash? The following script gives me an "uninitialized value" error (on the
marked line). I've read through the referencing  sections of MPPE and the
Camel book and neither seems to address this. The code, if modified to not
use the DBM file, works fine so I'm led to believe the problem has to do
with the DBM file. Is there an additional step I need to be taking?


use AnyDBM_File;
use Fcntl;

$pathToDBMFile = "stingray:Desktop Folder:userPass.dbm";
@steve = ("blue", "grape", "43", "31");
@darin = ("green", "orange", "265", "33");
@chris = ("yellow", "apple", "86", "30");

tie(%userArray, 'AnyDBM_File', $pathToDBMFile, O_CREAT | O_RDWR, 0666) 
  or die ("Couldn't create DBM file! $!");
 $userArray{"steve"} = \@steve; 
 $userArray{"darin"} = \@darin;
 $userArray{"chris"} = \@chris;
untie(%userArray);

tie(%myArray, 'AnyDBM_File', $pathToDBMFile, O_RDONLY, 0666) 
  or die ("Can't open for reading DBM File! $!");
 foreach $keyVal (keys (%myArray)){
  print "value: ${$myArray{$keyVal}}[1]\n"; #<- problem is here!
 }
untie(%myArray);



Thanks,
Steve


***********************************
Stephen M. Gray
Webmaster
Trendmasters - www.trendmasters.com

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch