This is a module math.pm
with 2 basic functions add and multiply:
package Math;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(add multiply);
sub add {
my ($x, $y) = @_;
return $x + $y;
}
sub multiply {
my ($x, $y) = @_;
return $x * $y;
}
1;
This is script script.pl
that call the add function:
#!/usr/bin/perl
use strict;
use warnings;
use Math qw(add);
print add(19, 23);
It gives an error:
can't locate math.pm in @INC <@INC contain: C:/perl/site/lib C:/perl/lib .> at C:\programs\script.pl line 5. BEGIN failed--compilation aborted at C:\programs\script.pl line 5.
How to solve this problem?