in reply to MLDBM and Memory

With about 10K keys, this might not be a killer issue, but you might notice a difference:
foreach my $key (keys %hash_db) # creates a list in memory # containing all key strings # vs. while ( my ($key, $val) = each %hash_db ) # iterates over the DB entries one at a time # and doesn't hold all keys in memory at once

Replies are listed 'Best First'.
Re: Re: MLDBM and Memory
by NormalPerson (Initiate) on Jun 02, 2004 at 06:18 UTC

    True. Sometimes we need to sort the keys, but using foreach without good reason is poor programming.