in reply to Clear / Initialize multiple hashes
I just want to check if this is a viable way to clear or initialize a set of hashes:
No. Your code does nothing.
This bit: %_ = () would assign nothing to the hash %_; which is probably empty anyway.
But that code is never invoked because this bit: for my(%hash1,%hash2,%hash3); doesn't result in anything, so the for never iterates.
The overall effect of you code is exactly the same as just: my(%hash1,%hash2,%hash3);
And the only reason "it seems to work fine"; is because it is not necessary to clear or initialise variables when you declare them.
Any variable declared with my, is a new clean, empty variable. You don't need to do anything to it to make it so.
|
|---|