[ABE.pm] Inhertance
Faber J. Fedor
faber at linuxnj.com
Fri Mar 9 09:04:50 PST 2007
On 07/03/07 13:12 -0500, Ricardo SIGNES wrote:
> * Faber Fedor <faber at linuxnj.com> [2007-03-07T12:42:17]
> > Am I correct in wanting to do this: create an object called OtherOne
> > that inherits from ClassOne and has a function called myAverage which
> > is actually myOtherAverage?
>
> Yes.
>
> # FILE Averager.pm
> package Averager;
<snip>
> 1;
>
> Then:
>
> # FILE Averager/Int.pm
> package Averager::Int;
> use base qw(Averager);
That looks simple enough, which explains why it's not working. :-)
I created a directory in /home/faber/libs/report called Benchmark and
created a file within it called RankReport.pm. The top of RankReport.pm
looks like:
#!/usr/bin/perl
package Benchmark::RankReport;
use strict;
use warnings;
use lib '/home/faber/libs';
use nycadb;
use lib '/home/faber/libs/reports';
use base qw(Benchmark);
and the contents are some functions I've copied over from Benchmark.pm
(the myOther* functions :-).
I've changed 'use Benchmark;' to 'use Benchmark::RankReport;' in my
script and change the called
$rb = Benchmark->new();
to
$rb = RankReport->new();
which doesn't work, but
$rb = Benchmark::RankReport->new();
does work.
I haven't had to do that (prepending the parent class) in the past with CPAN modules so I'm wondering
if I'm doing it right.
--
Regards,
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701
http://www.linuxnj.com
More information about the ABE-pm
mailing list