Krishna Priya Krishna Priya - 4 months ago 15
Perl Question

error in object creation in perl

I have created a class called person_b and i am trying to create an object for the same class in main function and trying to access the function in person_b class.but it is throwing an error called
Can't locate object method "name" via package "main" at main_b.pl line 5.

person_b.pm

package person_b;
sub new
{
$class=shift;
$self={};
bless($self,$calss);
return $self;
}
sub name
{
print "The name is ....\n";
}
1;


main.pl

use person_b;
use Scalar::Util 'blessed';
$per=new person_b();
print blessed($per),"\n";
$per->name();


output:-

main
Can't locate object method "name" via package "main" at main_b.pl line 5.

Answer
    bless($self,$calss);
                 ^^^^^

Typo?