Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Tie, DBM's, HoH and Sparse Keys

by TheoPetersen (Priest)
on Apr 11, 2001 at 00:13 UTC ( [id://71472]=note: print w/replies, xml ) Need Help??


in reply to Tie, DBM's, HoH and Sparse Keys

I tried this (Perl 5.6.1, RedHat 6.0) and found something wierd.
checkdbm \%terms,$db; print "hashref =", tied($terms{$db}), "\n";
prints "hashref =" and the use of uninitialized value warning. So the tiedness of the hash reference is getting lost somewhere.

Replies are listed 'Best First'.
Re: Re: Tie, DBM's, HoH and Sparse Keys
by mr.nick (Chaplain) on Apr 11, 2001 at 00:17 UTC
    Yeah, that didn't work quite as expected, so I followed runrigs suggestion and changed it to:
    sub checkdbm { my $hashref=shift; my $key=shift; if (-f "$key-dbm.db") { return; } my %hash; tie (%hash,'NDBM_File',"$key-dbm",O_RDWR|O_CREAT,0640); $hashref->{$key}=\%hash; }
    which works .. sorta. The DB files fill with the correct information, but my memory usage isn't any less. Odd, no?

    Well, off to Storable I suppose (and I was really trying to get THIS to work ... for stubborness sake).

      If speed is not of the essence...

      Could you try untying the hashes in between operations on particular top-level keys? That should release the NDBM_File buffers and what-not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://71472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found