⭐ in reply to How do I empty out a hash?
Hi,
To delete a key, you don't need to know her value.
Here's my code :
To delete a key, you don't need to know her value.
Here's my code :
Update: Of course this makes use of map in void context. Yick. And a couple other suggestions came in by way of followup:my %hash = ( Carol => 22, Mary => 21, Chris => 30 ); map { delete $hash{$_} } keys %hash;
- delete @hash{(keys %hash)}; # Hash slice
- %hash = (); # Most efficient method.
Arnaud
In Section
Seekers of Perl Wisdom