blazar has asked for the wisdom of the Perl Monks concerning the following question:

I've been searching a module to spell out numbers: it's been somewhat difficult (this is the subject of another question) but after some tries I found Math::BigInt::Named, although I didn't really needed something suited for big integers... However I installed it (under ActivePerl on a Windows system, with ppm - module version 0.03) but now I have problems with it. Namely:

C:\temp>perl -MMath::BigInt::Named -e "Math::BigInt::Named->new(42)" Can't locate object method "new" via package "Math::BigInt::Named" at +-e line 1. C:\temp>perl -MMath::BigInt::Named -e "Math::BigInt::Named->name(42)" Can't locate object method "new" via package "Math::BigInt::Named" at +C:/Program mi/Perl/site/lib/Math/BigInt/Named.pm line 41.

Giving a peek into the module's source, it clearly inherits from Math::BigInt, so M::BI's new() should be called. Or when one tries directly with name(), then Math::BigInt::Named::English's new() (or whatever language's) is called. But the latter also inherits from M::BI::N and thus M::BI, and does not define its own new(). OTOH if I use M::BI::N::E directly, I get:

C:\temp>perl -MMath::BigInt::Named::English -e "Math::BigInt::Named::E +nglish->ne w(42)" Can't locate object method "new" via package "Math::BigInt::Named::Eng +lish" at - e line 1. C:\temp>perl -MMath::BigInt::Named::English -e "Math::BigInt::Named::E +nglish->na me(42)" Can't locate object method "new" via package "Math::BigInt" at C:/Prog +rammi/Perl /site/lib/Math/BigInt/Named/English.pm line 15.

Replies are listed 'Best First'.
Re: Problem with Math::BigInt::Named
by syphilis (Archbishop) on Aug 28, 2007 at 11:44 UTC
    Math::BigInt::Named needs version 1.78 of Math::BigInt. I have only version 1.77 of M::BI ... and I get the same errors as you. I haven't upgraded M::BI to 1.78 to check that it fixes the problem, but I strongly suspect that's all that's wrong.

    Cheers,
    Rob

      Well, a peek into the source as I have it doesn't seem to show that M::BI::N needs any particular version of M::BI and also, in my case:

      C:\>perl -MMath::BigInt=9999 Math::BigInt version 9999 required--this is only version 1.87 at C:/Pr +ogrammi/Pe rl/lib/Exporter/Heavy.pm line 121. BEGIN failed--compilation aborted.

      OTOH

      C:\>perl -MMath::BigInt -e "Math::BigInt->new(42)" Math::BigInt::FastCalc is missing method '_from_oct' at -e line 0 Cannot load outdated Math::BigInt::FastCalc v0.10, please upgrade at - +e line 0

      So I'd better upgrade anyway. This still doesn't explain why the new() method can't be found...

      Update: I upgraded Math::BigInt::FastCalc and the problem with M::BI went away. That with M::BI::N stays though.

Re: Problem with Math::BigInt::Named (luke)
by tye (Sage) on Aug 28, 2007 at 13:41 UTC
    package Math::BigInt::Named; require 5.006001; use strict; use Math::BigInt::Named; use vars qw($VERSION @ISA $accuracy $precision $round_mode $div_scale); @ISA = qw(Math::BigInt);

    Does it make any sense for the module to try to use itself? Submit a patch that drops "::Named" from the 4th statement of the module. To work around the problem w/o fixing the module, add require Math::BigInt; to your own code.

    - tye        

      Or just use base Obi-Wan, ain't it right? (Joking, joking!) Anyway I'll try to contact the author ASAP. Thank you.

      C:\>perl -MMath::BigInt -MMath::BigInt::Named -le "print Math::BigInt: +:Named->name(42)" fourtytwo