Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Rea: DBM problem

by baku (Scribe)
on Feb 15, 2001 at 21:11 UTC ( #58652=note: print w/ replies, xml ) Need Help??


in reply to Re: DBM problem
in thread DBM problem

If you're concerned about disc space, though, I'm going to assume that the files are very large, ergo, unlikely to fit in memory... you'd likely want to do something like:

dbmopen %ORIG, "original", 0666 or die; dbmopen %NOVA, "new", 0666 or die; # -- race condition start for my $key (keys %ORIG) { $NOVA{$key} = $ORIG{$key}; } dbmclose %ORIG; dbmclose %NOVA; unlink "original" link "new", "original" # race condition end unlink "new";

So long as no-one else needs to get at your DBM while you're "shrinking" it, the above will work.


Comment on Rea: DBM problem
Download Code
Re: Rea: DBM problem
by japhy (Canon) on Feb 15, 2001 at 21:14 UTC
    But keys() will still build quite a large list. You may prefer while (my($k,$v) = each %hash) instead.

    japhy -- Perl and Regex Hacker

      Better yet :-)

Re: Rea: DBM problem
by merlyn (Sage) on Feb 15, 2001 at 22:53 UTC
    That won't work unless you know how to turn "new" into the actual list of files involved for that database. Perhaps "new.db", or even "new.dir" and "new.page".

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-07-10 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (215 votes), past polls