Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Clear / Initialize multiple hashes

by BrowserUk (Pope)
on Sep 19, 2013 at 18:05 UTC ( #1054891=note: print w/replies, xml ) Need Help??

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.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054891]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2018-03-21 10:40 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (265 votes). Check out past polls.