$ref = {}; # why won't this replace the underlying hash?
$ref is a scalar that holds a reference to a hash. {} creates a new anonymous hash, and you're overwriting the hashref with a reference to the new anonymous hash. In other words, you're just changing which hash $ref points to. To clear the hash pointed to by the reference, you need to dereference it: %$ref = (); will clear the hash pointed to by $ref (without removing the blessing).
In reply to Re: unexpected behavior on hash passed by reference
by haukex
in thread unexpected behavior on hash passed by reference
by perlfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |