I am trying to write a simple code using object oriented concepts, but could not.
Can anybody please help.
File name : Mycalc.pm
-------------------------------
#!/usr/bin/perl
Package Mycalc;
sub _area {
my $length = shift;
my $breadth = shift;
return $length * $breadth;
}
sub _perimeter {
my $length = shift;
my $breadth = shift;
return 2 *( $length + $breadth );
}
1;
------------
File name : test.pl
#!/usr/bin/perl
use Mycalc;
my $area = &_area(5,6);
print $area;
------------
Getting errors
Undefined subroutine &main::_area called at test.pl line 4.