Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Global variable vs passing variable from sub to sub

by Wassercrats (Initiate)
on Sep 15, 2004 at 02:08 UTC ( [id://391049]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Global variable vs passing variable from sub to sub
in thread Global variable vs passing variable from sub to sub

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^5: Global variable vs passing variable from sub to sub

Replies are listed 'Best First'.
Re^6: Global variable vs passing variable from sub to sub
by dragonchild (Archbishop) on Sep 15, 2004 at 02:27 UTC
    I'm not such a people.

    Ok. No-one says you have to do it. We're simply explaining why we choose to 'use strict', initialize every variable, scope things as tight as possible, and all that other crap.

    I don't know what would take more time, debugging such bugs or initializing every variable. The former is rare. The latter would have to be done all the time.

    Personally, I find it a lot easier to declare every variable immediately, because it helps me keep track of things. That may not be a concern of yours, so my experiences may not have relevance to you. I also prefer to have Perl determine when I typo something vs. running a separate program. Again, different strokes.

    I also find it helpful to scope variables as tightly as possible, because it helps me understand the code I just wrote. I choose to keep as few details in my head as possible. This requires me to organize my code in a certain way, so that I can immediately understand the code I wrote in a glance. Again, I am not saying that I have "The Holy Writ"(tm) when it comes to coding styles. I'm only describing those practices that help me, personally, and explaining why I recommend them to people who ask.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found