Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by naturalsciences (Beadle)
on Nov 11, 2011 at 18:29 UTC ( #937649=note: print w/ replies, xml ) Need Help??


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
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 use strict; -- 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 (Abbot) 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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-12-27 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls