Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Are global variables "bad"?

by jpearl (Scribe)
on Apr 21, 2009 at 17:23 UTC ( [id://759061]=note: print w/replies, xml ) Need Help??


in reply to Re: Are global variables "bad"?
in thread Are global variables "bad"?

Thanks DStaal,to be honest, coming from a java background, I definitely am drawn towards making this object oriented. Actually creating the getter and setter functions were definitely an attempt to emulate OO style programming in my (currently) almost completely functional style program. I certainly am eying perl OO surreptitiously, but then I'd have to figure out how bless works. Though, I suppose that's probably going to have to happen soon anyway.

Replies are listed 'Best First'.
Re^3: Are global variables "bad"?
by DStaal (Chaplain) on Apr 21, 2009 at 17:40 UTC

    Quick version on bless: It marks a reference as an object. The reference can be to any type of varible: scalar, array, hash, are all common. You will need to figure out some way of accessing the data you want to access as the object's data based on the contents of that variable.

    Common strategies include: just putting it in the scalar (for simple data), or array/hash (for more complex); and putting a key into some other data structure into the variable (inside-out uses package-level hashes, with the key being the blessed variable's address. Some people like to use arrays, for faster access.).

      For some reason that's the first explanation that's made sense :-P I will definitely have to do some more homework before I get to crazy, but my fingers are itching for a few practice problems.

Log In?
Username:
Password:

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

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

    No recent polls found