BaseClass.pm
package Test::Base::BaseClass;
sub new {
return bless {hello=>@_[0],person=>@_[1]} , __PACKAGE__;
}
sub hello {
print "hello";
}
sub person {
my $self = shift;
return $self->{person};
}
1;
Sub.pm
package Test::Base::BaseClass;
sub sub_ {
my $self= shift;
print __PACKAGE__;
}
1;
example.pl
use lib 'C:/Users/pavan.t/workspace/Simple';
use Test::Base::BaseClass;
$sub = Test::Base::BaseClass->new('pavan','pavan');
print $sub->person;
print $sub->sub_
我有一个 BaseClass 包和另一个模块 Sub.pm 属于同一个包。
在我的示例程序中,当我调用该sub_
方法时,它会打印以下错误:
无法通过 C:/Users/pavan.t/workspace/Simple/ExampleOnBase.pl 第 12 行的包“Test::Base::BaseClass”找到对象方法“sub_”。