talwyn has asked for the wisdom of the Perl Monks concerning the following question:
The following code tells me that no new sub can be found in package STRTicket. While true technically... the @ISA is supposed to enable inheritance... I thought. In this case the empty sub class fails.
All classes are in the same monolithic source file. USE doesn't appear to like that and searches for actual .pm files... so I used import which seems to give me the symboltables (Ticket->new works for instance... but inheritance appears to fail ( Empty sub-class test fails). So What... if anything else am I supposed to do when everything is in a single file to use an object and its subclasses?
my $t = new STRTicket(); package Ticket; sub new { my $class = shift; my $ticketid = shift; my $self= { 'TICKETID' => undef, 'SOURCE' => undef, 'CREATEDBY' => undef, 'OWNER' => undef, 'MODIFIEDBY'=> undef, 'CREATEDON' => undef, 'MODIFIEDON'=> undef, 'COMPANYNAME'=> undef, 'STATE' => undef, 'STATUS' => undef, 'BZTICKETS' => (), 'AGE' => undef, 'TITLE' => undef, }; bless $self, $class; if ( defined $ticket) { $self->{'TICKETID'} = $ticket; } else { die "Ticket object instantiated without a ticket id! This shou +ld never happen.\n"; } return $self; } sub load_bztickets($){ my $self= shift; my $dbh = shift; # pass in the database reference for Bugzilla } 1; package BZTicket; import Ticket; # use Ticket; @ISA = ('Ticket'); 1; package CRMTicket; import Ticket; #use Ticket; @ISA = ('Ticket'); 1; package STRTicket; import Ticket; # use Ticket; @ISA = ('Ticket'); 1;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Possibly Stupid OOP question
by ysth (Canon) on Feb 27, 2008 at 02:13 UTC | |
by tye (Sage) on Feb 27, 2008 at 03:24 UTC | |
by jepri (Parson) on Feb 27, 2008 at 06:12 UTC | |
by tye (Sage) on Feb 27, 2008 at 06:36 UTC | |
Re: Possibly Stupid OOP question
by NetWallah (Canon) on Feb 27, 2008 at 01:42 UTC | |
Re: Possibly Stupid OOP question
by runrig (Abbot) on Feb 27, 2008 at 00:32 UTC | |
by talwyn (Monk) on Feb 27, 2008 at 00:38 UTC | |
by runrig (Abbot) on Feb 27, 2008 at 00:43 UTC | |
Re: Possibly Stupid OOP question
by runrig (Abbot) on Feb 27, 2008 at 00:52 UTC | |
by talwyn (Monk) on Feb 27, 2008 at 01:06 UTC | |
Re: Possibly Stupid OOP question
by dsheroh (Monsignor) on Feb 27, 2008 at 04:06 UTC | |
Re: Possibly Stupid OOP question
by ikegami (Patriarch) on Feb 27, 2008 at 06:48 UTC |
Back to
Seekers of Perl Wisdom