Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Problem with dbm hash?!!

by nagalenoj (Friar)
on May 06, 2009 at 13:14 UTC ( #762267=perlquestion: print w/ replies, xml ) Need Help??
nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:

when I have a requirement to store big hashes and process it, I use DBM hashes. But, recently I have heard that using DBM hashes is not a good idea. Is it so? Kindly clarify me why it is so.?

Comment on Problem with dbm hash?!!
Re: Problem with dbm hash?!!
by jettero (Monsignor) on May 06, 2009 at 13:17 UTC
    Who says? It probably depends on the problem space, but I'm not personally aware of any problems with using DBM Hashes. If you want to store really huge perl structures consider DBM::Deep -- it's neat, but not really related to DBM as far as I know.

    Also, I just realized I was thinking DB_File hashes, which I use from time to time. Did you mean something else?

    UPDATE: nearly the same thing. In fact, for all we know, dbmopen may just use DB_File... see: AnyDBM_File. Regardless, I think those are just fine for smaller apps. For apps with a lot of concurrency or application interactions, maybe a real database is better. It depends. Few solutions are right for all problems. That's part of the reason there's more than one way to do it.

    -Paul

      Thanks for you reply. Actually, I have not used DB_File.

      I use dbmopen(), dbmclose() like follows,

      #!/usr/bin/perl use strict; use warnings; my %hash; # To open a dbmfile and associate with hash dbmopen(%hash, "nagalenoj", '0666') || die "Can't open database file!" +; $hash{'one'}="1"; $hash{'two'}="2"; $hash{'three'}="3"; #Retrieving values print $hash{'three'}; dbmclose %hash;
Re: Problem with dbm hash?!!
by moritz (Cardinal) on May 06, 2009 at 13:18 UTC
    I don't see what's wrong with it, as long as you want to store flat hashes. dbm doesn't support nested data structures, which could be a pain if you need them.
Re: Problem with dbm hash?!!
by vinoth.ree (Parson) on May 06, 2009 at 14:19 UTC

      Hmmm... I wonder if the Applied Research Lab of the Washington University in St. Louis got permission from the copyright holder, O'Reilly & Associates, to host The Perl CD Bookshelf on its website. I doubt it...

      HTH,

      planetscape

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://762267]
Approved by jettero
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-12-20 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls