Skip Menu |

This queue is for tickets about the Math-Counting CPAN distribution.

Report information
The Basics
Id: 76803
Status: resolved
Worked: 45 min
Priority: 0/
Queue: Math-Counting

People
Owner: Nobody in particular
Requestors: mjp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.0902
Fixed in: (no value)



=Issue= Math::Counting fails to use or require 'Exporter', meaning that the simplest usage doesn't work: $ perl -MMath::Counting -le 'print Math::Counting->VERSION; print factorial(3)' 0.0902 Undefined subroutine &main::factorial called at -e line 1. I expected this to print "0.0902\n6\n", rather than the above. Note that unit tests pass. Test::More conceals this omission, unfortunately, because it loads Exporter.pm. (I have filed a separate bug for consideration under the Test::Simple suite.) =Proposed Fix= 'use Exporter' in Math/Counting.pm, or drop the ISA manipulation and 'use base qw(Exporter)' =Misc= See here for real world problem and discussion: http://stackoverflow.com/q/10318313/132382
Actually, "use Exporter qw(import)" is all that's needed. (No @ISA / inheritance, as pointed out in the aforementioned link.)
Subject: Exporting
Thank you for pointing out that I forgot to require Exporter. Oof. I have released a new, corrected version. So now the command line syntax works: Show quoted text
> perl -MMath::Counting=:student -le 'print Math::Counting->VERSION; print factorial(3)'
0.0903 6 (Notice that you need to declare what you want, in -M, to import the right function set, as documented in the SYNOPSIS.) Thanks again, Gene On Wed Apr 25 09:13:33 2012, MJP wrote: Show quoted text
> =Issue= > Math::Counting fails to use or require 'Exporter', meaning that the > simplest usage doesn't work: > > $ perl -MMath::Counting -le 'print Math::Counting->VERSION; print > factorial(3)' > 0.0902 > Undefined subroutine &main::factorial called at -e line 1. > > I expected this to print "0.0902\n6\n", rather than the above. > > Note that unit tests pass. Test::More conceals this omission, > unfortunately, because it loads > Exporter.pm. (I have filed a separate bug for consideration under the > Test::Simple suite.)
On Wed Apr 25 12:59:48 2012, GENE wrote: Show quoted text
> (Notice that you need to declare what you want, in -M, to import the > right function set, as > documented in the SYNOPSIS.)
Thanks, Gene. You need to change @EXPORT to @EXPORT_OK if that's what you mean. Otherwise, "use Math::Counting" will pull in all the symbols in @EXPORT once the Exporter mechanics are loaded. Regards, Mike
Subject: Re: Exporting
Ok. I've changed EXPORT to EXPORT_OK. This allows individual functions to be exported, as well as the :student and :big tags. Show quoted text
> perl -Ilib -MMath::Counting=:student -le 'print Math::Counting->VERSION; print
factorial(3)' 0.0904 6 Show quoted text
> perl -Ilib -MMath::Counting=factorial -le 'print Math::Counting->VERSION; print
factorial(3)' 0.0904 6 Show quoted text
> perl -Ilib -MMath::Counting -le 'print Math::Counting->VERSION; print factorial(3)'
0.0904 Undefined subroutine &main::factorial called at -e line 1. Fixed and released. On Wed Apr 25 10:05:36 2012, MJP wrote: Show quoted text
> On Wed Apr 25 12:59:48 2012, GENE wrote:
> > (Notice that you need to declare what you want, in -M, to import the > > right function set, as > > documented in the SYNOPSIS.)
> > Thanks, Gene. You need to change @EXPORT to @EXPORT_OK if that's what > you mean. > Otherwise, "use Math::Counting" will pull in all the symbols in > @EXPORT once the Exporter > mechanics are loaded. > > Regards, > Mike
-- -gb Epistemologist-at-large