SPUG: Re: need help with Class::Methodmaker and tieing hash to DBM
Dan Roscigno
roscign1 at roscigno.com
Mon Mar 1 18:18:46 CST 2004
Here is an update, I have added the code to create the DBM file:
##############################################################
use DB_File;
use Class::MethodMaker
[ new => [qw/ -hash new /],
hash => [{ -tie_class => 'DB_File',
-tie_args => [ '/tmp/datum.db',
O_APPEND|O_RDWR,
0666, $DB_HASH],
} => 'datum' ],
];
##############################################################
Now I see the file created in /tmp/, and when I store a value in the
hash 'datum' I can read it back, but the data does not appear to be
persitent. On a second run of the code the only value I can see is
the current data.
Dan Roscigno
On Mon, 1 Mar 2004, Dan Roscigno wrote:
>
> Hi All,
> I am trying to figure out how to tie a hash to a DBM file whie using
> Class::Methodmaker. Here is what I think I do:
>
> 1) subclass Tie::Hash with methods that use MLDBM
> 2) specify the above subclass in the use Class:Methodmaker statement
>
> Is this correct? If so then what I am looking for is some hand
> holding with step 1. I am guessing that I would want to look at the
> name of the object and the hash that is tied and use that to specify
> my DBM file. I have never worked with tie or DBM before, so I am
> not too sure about this. If someone could give me a nudge in the
> correct direction I think I can get started.
>
> Thanks,
> Dan Roscigno
>
>
>
>
More information about the spug-list
mailing list