Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Answer: How do I empty out a hash?

by Aristotle (Chancellor)
on Oct 04, 2003 at 16:10 UTC ( #296526=note: print w/replies, xml ) Need Help??


in reply to Re: How do I empty out a hash?
in thread How do I empty out a hash?

Easier yet.
delete @hash{(keys %hash)};
Update: this is, of course, only useful when you want to use delete the keys from one hash in another one, as in
delete @foo{(keys %bar)};
Otherwise, only the below solution makes any sense.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Answer: How do I empty out a hash?
by Anonymous Monk on Oct 04, 2003 at 16:23 UTC

    Even more easier!

    %hash = ();

    And twice more quicker also.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-11-26 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?