Need help with extending my Perl module
I am trying to extend my company specific BaseClass (Acme::BaseClass) but whenever I:
package Manager;
use strict;
use warnings;
use ba开发者_如何转开发se qw(Acme::BaseClass)
sub new { ...
it gives me the error:
Base class package "Acme::BaseClass" is empty.
But in my script I can use the package fine:
use Acme::BaseClass;
my $bc = BaseClass->new("myname");
$bc->prnt(); # prints "myname"
exit;
This is my first time trying to inherit in Perl so maybe I am missing something basic?
NOTES:
- I have tried using "parent" and it also does not work
I tried to use the old school :
BEGIN { require Acme::BaseClass; push @ISA, qw(Acme::BaseClass); }
I am unsure how to do these correctly either. Hopefully it is something simple I am missing. If nobody can answer it I will add more details.
Judging from your code sample, it sounds like Acme/BaseClass.pm
has something like this in it
package BaseClass;
....
1;
and it needs
package Acme::BaseClass;
....
1;
Possibly the child class cannot find the BaseClass module but your test script can. Check @INC is setup correctly so that both can find your module.
精彩评论