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

Re: [MacPerl-AnyPerl] storing a DBM file



On 8/3/99 at 7:41 AM, pudge@pobox.com (Chris Nandor) wrote:

> At 18.28 -0500 1999.08.02, Adam Price wrote:
> >    So....how do I save that dbm file?  Why doesn't this work?
> >
> >     dbmopen(%saveparsed, 'parsed.nsh', 0666) || die ("Could not open: $!");
> > %saveparsed =%parsed;
> >
> >  dbmclose(%saveparsed) ||die "Couldn't dbmclose: $!"
> >
> >  Nor error messages, it just won't hold values which I know are there in
> >%parsed.
> 
> Beats me.  What is in %parsed?  Is it a complex data structure containing
> references (in which case it has already been pointed out that this will
> fail miserably) or is it a simple hash?


%parsed has a inventory number in the key, and and 8 fields list in the value. 
The 8 fields are all simple text: title, author, date 1st published and so on.
Here is a simplified version of what I am shooting for.  It also doesn't "work
right."

####################CODE#############
#!perl 

@list_1 = qw (pig dog cat horse elephant tapir); 
@list_2 = qw (north east south west up down);
@list_3 = qw (apple orange papaya goyaba plum);

$parsed{1} =[ @list_1];
$parsed{2} =[ @list_2 ]; 
$parsed{3} =[ @list_3];
    
%saveparsed =%parsed;

foreach $num (keys %saveparsed) {
    print STDOUT "\nSAVEPARSED $num:  @{ $saveparsed{$num} }  ";}

dbmopen(%saveparsed, 'parsed.nsh', 0666) || die ("Could not open parsed: $!");
 %saveparsed =%parsed;
foreach $num (keys %saveparsed) {
    print STDOUT "\nSAVEPARSED_x $num: @{ $saveparsed{$num}}  ";}
dbmclose(%saveparsed) ||die "Couldn't dbmclose: $!"


############OUTPUT##################
SAVEPARSED 1:  pig dog cat horse elephant tapir
SAVEPARSED 2:  north east south west up down  
SAVEPARSED 3:  apple orange papaya goyaba plum  
SAVEPARSED_x 2:   
SAVEPARSED_x 1:   
SAVEPARSED_x 3:   

######
I had expected it would give the same output in both print loops (with the
exception of the "_x" of course.)



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org