I am trying to use a module called Math::Counting:
#!/usr/bin/perl 
use strict;
use warnings;
use Math::Counting;
my $f = factorial(3);
print "$f\n";
When I run it however, I get the following error
$ perl UsingModules.pl
Undefined subroutine &main::factorial called at UsingModules.pl line 8.
It seems like the function factorial is not being exported, but why?
When I used the following
my $f = Math::Counting::factorial(3);
instead of what was above, it works perfectly fine, but I am curious why the function cannot be exported.
I am using perl v5.10.1 on Cygwin.
There is a bug in the module. Math::Counting ISA Exporter, but Math::Counting does not load Exporter.
Workaround: You can require or use Exporter manually.
Better: File a bug with the module author, provide a test case.
Oh, very interesting.  The module author does test his functions, but Test::More pulls in Exporter, meaning that this omission from the module source was not noticed.
Math::Counting 0.0904 has been released, addressing this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With