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 22: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 22: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