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

Hi!

I have a Perl program that uses the Math::Trig module. The program works fine (apparently) but I get this warning when I execute it:


Prototype mismatch: sub main::tan (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14


actually, line 14 is the module call:


use Math::Trig;


I reinstalled both Math::Trig and Exporter but the issue persists. Any thoughts?

UPDATE: Sorry forgot to add the the mentioned warning line is only the first, and that a warning message appears for all and each one of the methods:

Prototype mismatch: sub main::tan (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::asin (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::acos (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::atan (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::sinh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::cosh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::tanh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::asinh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::acosh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Prototype mismatch: sub main::atanh (;@) vs none at /usr/lib/perl5/5.10.0/Exporter.pm line 67, <DATA> line 387. at hogg.pl line 14

Replies are listed 'Best First'.
Re: Strange warning when using Math::Trig
by LanX (Saint) on Nov 11, 2008 at 12:25 UTC
    Hi

    I never used the module, but while importing the new trigonometric functions a prototype conflict occurs, meaning the allowed parameters differ from a previous definition.

    The modules pod says (in the "Bugs"-Paragraph): "Saying use Math::Trig; exports many mathematical routines in the caller environment and even overrides some (sin, cos)."

    Did you use any other modules overiding these functions prior to import Math::Trig? If yes does this "problem" still occure when you only use Math::Trig?

    If not you might want to ignore or disable these warnings. Or better contact the author.

      Thanks for your answer! That was exactly what happened: I had a "use PDL;" call from an older version of the program that I forgot to delete.
Re: Strange warning when using Math::Trig
by almut (Canon) on Nov 11, 2008 at 12:57 UTC

    I know your problem is already solved... but maybe it's worth knowing that you always have the option to avoid such name clashes by saying

    use Math::Trig ();

    The empty parentheses tell a module to not auto-import anything into your namespace. You can then call the functions fully-qualified as needed, e.g. Math::Complex::tan(...).

      Thanks almut, that's a pretty good advice.
      cheers