Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: OOP Access of variables

by TheoPetersen (Priest)
on Mar 08, 2001 at 16:38 UTC ( [id://63024]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: OOP Access of variables
in thread OOP Access of variables

Assuming the code I gave you, there would be only one $dbh. (Hey, that's a catchy phrase ... :)

When learning Perl objects (or Perl anything else), follow your hunches and try them out. You'll develop both knowledge and intuition quickly. That's the nice thing about Perl's learning curve, you can almost always do useful work along the way.

Replies are listed 'Best First'.
Re: Re: Re: Re: OOP Access of variables
by simeon2000 (Monk) on Mar 08, 2001 at 17:02 UTC
    Theo: You were right! I forgot that Packages and the object they create are separate. I figured for each Article or Editor I created, there'd be a new $dbh handle, but since it's global in TArtLib, the ref on the $dbh returned the same memory address for both packages' copy of $TArtLib::dbh :) Thanks so much to everyone for help. I learned a lot more about packages and objects today :)
Re: Re: Re: Re: OOP Access of variables
by Masem (Monsignor) on Mar 08, 2001 at 17:46 UTC
    I'd just add in here for clarification of the SoPW poster that $dbh is a reference to your database object (the arrow operator for the DBI functions should be a big tip-off :D); using the "my $dbh = TArtLib->dbh();" anywhere else gains you a local copy fo the reference, but the reference still points to the single copy of the object that holds the DB connection.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63024]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.