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

Re^5: Array name with a Variable

by mr_mischief (Monsignor)
on Apr 17, 2008 at 20:59 UTC ( #681298=note: print w/ replies, xml ) Need Help??

in reply to Re^4: Array name with a Variable
in thread Array name with a Variable

Well, I think more specifically why the assignment and the declaration ended up inside the loop together that way was that I followed basically these steps:

  1. copied the original code with the declaration at the top
  2. modified the code to clear the hashes inside the loop to reuse them
  3. noticed the hashes weren't actually used outside the loop
  4. moved the "my" inside the loop with the assignment
  5. stopped, not paying any attention to the fact that I now had a useless assignment.

So you can see it was at some point useful, but I actually added smell to that portion of the code by refactoring carelessly. That's something to consider when thinking about changing working code, I guess.

Update: I guess the above should say I put the code to clear the hashes inside the wrong loop the first time around. See Re^3: Array name with a Variable for a corrected version (or see the responses by those who didn't screw up the scoping in the first place). ;-)

Comment on Re^5: Array name with a Variable

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2015-11-28 05:05 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (737 votes), past polls