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_
I have one BaseClass package and another module Sub.pm which belongs to same package.
In my example program, when i call the sub_ method, it prints the following error as:
Can't locate object method "sub_" via package "Test::Base::BaseClass" at C:/Users/pavan.t/workspace/Simple/ExampleOnBase.pl line 12.
sub new { return bless {hello=>@_[1],person=>@_[2]}, $_[0]; }- Brad Gilbert