Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Confused by OO & tie

by flyingmoose (Priest)
on May 17, 2004 at 15:51 UTC ( [id://354008] : note . print w/replies, xml ) Need Help??

in reply to Confused by OO & tie

However I had a feeling that tie had something to do with OO

You can disregard 'tie' as you learn OO. tie can be used to bind variables to objects so that in-memory variables (hashes for instance) actually do something else behind the scenes. An example might be a hash that really saved everything you wrote to a database, or maybe a hash that relayed all lookups to a remote server.

How's this work? Well, there is an object behind the scenes that masquerades as the hash... kinda sorta...

Anyhow, knowledge of tie is not required for any OO implementation, only if you want to, say, make a hash that has special magic behind the scenes. If you are just using a blessed hash reference to hold your object member data, you don't have to worry about tie. In fact, I've never found a need for it ... but if you have an existing block of code that works with a regular hash, the exact same code will work on a tied hash, and that makes tie interesting.

Also see "perldoc perltie" rather than "perldoc -f tie", as that seems to make a ton of more sense.

Replies are listed 'Best First'.
Re: Re: Confused by OO & tie
by Scarborough (Hermit) on May 17, 2004 at 15:57 UTC
    Thanks, I expect I'll be back later to find out more about tie as I have inherited some code that does ties to a type of resource block, unless of course you can guide me to a tie tutorial or resource a little more in depth than the perldocs mentioned in my post.