Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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]
[ovedpo15]: someone has experience with SlickEdit editor? I have it on Linux and I would like to debug my perl code from the shell. what is the commend to run it using the debbuger?
[marto]: perldebug, never heard of the editor

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-05-25 18:30 GMT
Find Nodes?
    Voting Booth?