in reply to Re: Re: Re: DBM
in thread DBM

if ($male) { $hash{$nameplace}{$person}->[0]++; } else { $hash{$nameplace}{$person}->[1]++; }
This is my present code
What i wanted to do is put this in to MLDBM.
The thing is, every place contains a
hash of people.
ie there are various persons for each name
place.
so i am not able to do it.
so if u cld be able to help me

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: DBM
by rdfield (Priest) on Nov 01, 2002 at 10:58 UTC
    From the docs:

    Declaring an MLDBM hash:

    use MLDBM; use Fcntl; $dbm = tie %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or die $!;
    and modifying an item:
    $tmp = $mldb{key}; # retrieve value $tmp->{subkey}[3] = 'stuff'; $mldb{key} = $tmp;
    which in your case would be something like:
    use MLDBM; use Fcntl; $hash = tie %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or die $!; ... $tmp = $hash{$nameplace}; if ($male) { $tmp->{$person}[0]++; } else { $tmp->{$person}[1]++; } $hash{$nameplace} = $tmp;
    (note this is untested...)

    rdfield