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

Re: [MacPerl] (de)referencing and DBM files



You might want to take a look at the MLDBM modules (available from CPAN).
It handles the serialization (using either Storeable or FreezeThaw) of
complex data structures and interfaces easily to DBM packges. (If you've
got a TIEHASH interface to your DBM then you're all set.)

Frank Riherd
>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
>



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