Reputation: 33
I have a perl Module
MyMathLib.pm
package MyMathLib;
require Exporter;
@ISA = qw/EXPORTER/;
@EXPORT = qw/add/;
sub add
{
$_[0] + $_[1];
}
1;
Ex1.pl
#!usr/bin/perl
#
use MyMathLib;
print add(1,2);
I am getting the below error:
Undefined subroutine &main::add called at ex1.pl line 4.
What could be the reason?
Upvotes: 3
Views: 3307
Reputation: 78115
It's an Exporter not an EXPORTER.
If you include
use strict;
use warnings;
in your scripts you'll activate more checks that would have shown you a clue to the problem:
Can't locate package EXPORTER for @MyMathLib::ISA at Ex1.pl line 5.
Undefined subroutine &main::add called at Ex1.pl line 6.
Upvotes: 4