Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Best practices with globals and subroutine arguments

by Herkum (Parson)
on Jun 07, 2010 at 14:34 UTC ( #843503=note: print w/ replies, xml ) Need Help??


in reply to Best practices with globals and subroutine arguments

I rarely, if ever use global variables, they don't really provide many benefits over objects or local variables and can potentially lead to many bugs.

If I were you, I would stick all my data into a readonly data object. Then you can pass your subroutines the data object instead. This way you can make your data specifically 'READONLY', ie: no gotchas which your subroutines "accidently" change a value.


Comment on Re: Best practices with globals and subroutine arguments

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-08-02 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (10 votes), past polls