mhacker has asked for the wisdom of the Perl Monks concerning the following question:
I can use the $db object without problems in the methods defined in the IDObject class. However, when I try to use it from a class that inherits from IDObject:package IDObject; my $db; sub set_db { $db = shift; }
I get error messages about not being able to execute search through and unblessed reference (I don't have the exact message here). I've tried using $SUPER::db, $this->{$db} and even $IDObject::db, but none of them works. Does anyone know how to solve this, or is this perhaps the wrong way to go about it? I know I can call my table class constructors and include the DB reference in the call. This looks ugly though, and it forces me to keep the DB reference in a global in my program.package Table; use DB; @ISA=qw(DB); sub fix_it { my $this = shift; my $what = shift; my $results = $db->search($what); . . }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class data and inheritance
by jdporter (Paladin) on Nov 07, 2002 at 14:37 UTC | |
by joe++ (Friar) on Nov 07, 2002 at 14:50 UTC | |
|
Re: Class data and inheritance
by broquaint (Abbot) on Nov 07, 2002 at 14:49 UTC | |
|
Re: Class data and inheritance
by joe++ (Friar) on Nov 07, 2002 at 14:36 UTC | |
|
Re: Class data and inheritance
by FamousLongAgo (Friar) on Nov 07, 2002 at 14:39 UTC |