tags:

views:

78

answers:

1

Possible Duplicate:
How can I reset a hash completely without using a for loop?

How do I empty a hash in Perl? I've got a code like this:

my %hash;
while (some_condition) {
    # do something
    if (deleting_condition) {
        # empty %hash
    }
}

My first idea was %hash={};, but this gives the hash a single value with a key of an empty hash. Deleting elements one by one soesn't seem very efficient.

+3  A: 

Either %hash = () or undef %hash will work.

eugene y