I would like to completely reset my %hash so that it does not contain keys or values at all. I prefer to use a one-liner than have to use a loop.
So far I have tried:
%hash = 0;
%hash = undef;
But these both throw errors in strict mode with warnings enabled, so I wrote a simple for loop to achieve the same thing:
for (keys %hash) {
delete $hash{$_};
}
This works but I would really like to do this with a one-liner. Is there a way to simply reset a hash that I am overlooking?
mynear the top. – I think this is an XY problem with room for algorithmic improvement, perhaps give some more context?mystatement. (It is possible that I am overlooking an XY problem since I did not know how to do something like reset a hash)