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

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.


Comment on Re: Clear / Initialize multiple hashes
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-07-11 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (219 votes), past polls