http://www.perlmonks.org?node_id=937649


in reply to Re^3: Why does this sub grab the whole hash
in thread Why does this sub grab the whole hash

Oh man - enlightenment just hit me. Looked over my code and now I got how this poor array was filled over and over again with some quite random stuff in the different parts of my script. Really bad idea to use a subs like this with a globally defined array.

  • Comment on Re^4: Why does this sub grab the whole hash

Replies are listed 'Best First'.
Re^5: Why does this sub grab the whole hash
by moritz (Cardinal) on Nov 11, 2011 at 18:32 UTC

    And that's why people always recommend to usestrict; -- it complains about undeclared variables, so it forces you to think about where to put the declaration. And you only put the declaration outside the subroutine if that's your conscious choice.

Re^5: Why does this sub grab the whole hash
by AnomalousMonk (Archbishop) on Nov 11, 2011 at 20:39 UTC
    Really bad idea to use a subs like this with a globally defined array.

    It's a really bad idea to use subs (or anything else) with a globally defined, non-constant anything unless, as moritz has written, it's your conscious decision to do so — and even then I'd think twice about it.