in reply to Re: Clear / Initialize multiple hashes
in thread Clear / Initialize multiple hashes

Thanks! both replies helped a lot. I thought it looked a little funky and thought I would check so I am really glad I did. Any suggestion on the best way to clear all of them? At initialization I can just do:

my(%hash1,%hash2,%hash3);

but later on if I want to clear all of them how should I go about it? I mean I could just clear each one individually, but when I have a long list that can be a bit of a pain...

Replies are listed 'Best First'.
Re^3: Clear / Initialize multiple hashes
by BrowserUk (Patriarch) on Sep 19, 2013 at 18:45 UTC
    but later on if I want to clear all of them how should I go about it?

    The simplest way is to scope them such that they get reinitialised by re-entering the scope each time you want to re-use them:

    for( some loop condition or contruct ) { my( %hash1, %hash2, %hash3 ); ## do stuff with them ... }

    Each time that loop iterates, the hashes will be reinitialised for you.

    But, it you really need to do it manually, you could use:

    undef %$_ for \(%h1,%h2,%h3);

    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.
Re^3: Clear / Initialize multiple hashes
by choroba (Cardinal) on Sep 19, 2013 at 18:23 UTC
    You can do
    ( %hash1, %hash2, %hash3 ) = (); # or %hash1 = %hash2 = %hash3 = ();
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ