in reply to Re: Re: Re: Re: Re: Global variables over many children
in thread Global variables over many children

Oh right. Can you give me a hint how it does that, I can only see how to do hashes at the moment. Simply replacing the hash with array gives:
TIEARRAY not handled by object MLDBM::Sync at /usr/lib/perl5/site_perl +/5.6.0/MLDBM/Sync.pm line 60.
Thanks

Replies are listed 'Best First'.
Re: RE: Global variables over many children
by perrin (Chancellor) on Dec 06, 2001 at 20:03 UTC
    Just put an array ref in one of the hash values. It works like MLDBM. $tied_hash{my_array} = [1,2,3];
      Im having a lot of trouble getting my head round this, sorry to be a nuisance. Ive tried the following:
      #!/usr/bin/perl -w use MLDBM::Sync; use Fcntl qw(:DEFAULT); $tied_hash{list} = [1,2,3,4,5]; #my $sync_dbm_obj = tie %tied_hash, 'MLDBM::Sync', '/tmp/mldbmsync', O +_CREAT|O_RDWR, 0640; push @{$tied_hash{list}},6; @values = @{$tied_hash{list}}; print @values;
      which prints 123456 as you would expect, but as soon as I uncomment the tie, nothing is printed.
      TIA
        Just a guess... try this: (untested)
        $tied_hash{list} = [1,2,3,4,5]; my $sync_dbm_obj = tie %tied_hash, 'MLDBM::Sync', '/tmp/mldbmsync', O_ +CREAT|O_RDWR, 0640; # modify list my $listref = $tied_hash{list}; push(@$listref,6); # store list back into hash. $tied_hash{list} = $listref; # did it work? @values = @{$tied_hash{list}}; print @values;

        -Blake

        Try doing the tie before you modify the hash. Also, check the MLDBM man page for examples.