Subject: | Can't call method Math::BigFloat->bsub, not a valid method |
In the class Math::BigFloat when you have fsub called out in your
program and it goes to Math::BigFloat to do the calculation it is
suppossed to alias back to bsub. It corectly aliases but the $class
variable is not correctly set to Math::BigInt where bsub sub-routine
is declared at, it is trying to find the bsub routine in the
Math::BigFloat module instead and since it is not there it fails out.
Heres my code snippet:
$sdate = new Math::BigFloat "365.25";
$mdate = new Math::BigFloat "30.6001";
$a = int($year/100);
$b = int($a/4);
$c = int((2 - $a)+$b);
$e = int($sdate*($year + 4716));
$f = int($mdate*($mon + 1));
$cdate = ((($c+$day)+$e)+$f);
$cdateStr = new Math::BigFloat( $cdate );
$cdateStr->fsub(1524);
$cdateStr->fabs($cdateStr);
And here is the code snippet out of Math::BigFloat:
my $name = $AUTOLOAD;
$name =~ s/(.*):://; # split package
my $c = $1 || $class;
no strict 'refs';
$c->import() if $IMPORT == 0;
if (!method_alias($name))
{
if (!defined $name)
{
# delayed load of Carp and avoid recursion
require Carp;
Carp::croak ("$c: Can't call a method without name");
}
if (!method_hand_up($name))
{
# delayed load of Carp and avoid recursion
require Carp;
Carp::croak ("Can't call $c\-\>$name, not a valid method");
}
# try one level up, but subst. bxxx() for fxxx() since MBI only
got bxxx()
$name =~ s/^f/b/;
return &{"Math::BigInt"."::$name"}(@_);
}
my $bname = $name; $bname =~ s/^f/b/;
$c .= "::$name";
*{$c} = \&{$bname};
&{$c}; # uses @_
}
The variable class is declared as thus:
my $class = "Math::BigFloat"; at line 25 in the Math::BigFloat module.
bsub is located in Math::BigInt at line 1130.
Perl Version 5.8.7 is distributed with this.
OS is Windows, Sun-Solaris, HP-Unix
Thanks, Mike