2

Why don't I have to use use Math::Trig; in my Perl program to call atan2()?

According to documentation, atan2() is not part of the "Perl Core".

I have Perl 5.18.4. I looked at the list of standard Perl modules, and I DO see Math::Trig listed, but I still thought that the "use" statement was required. Admittedly, my Perl knowledge is only about 6 months old at this point. So, a simple answer would be a quote from an official Perl document. Or, maybe there is something else going on here that I don't understand.

Here is an example of what I am talking about.

#!/usr/bin/perl
use strict;
use warnings;
$value = atan2(1, 1) * 4;
print "$value\n";

Output:

  3.14159265358979
0

2 Answers 2

5

You don't need to use Math::Trig; because atan2 is a built-in function. You can also see this from your command line:

perldoc -f atan2
1
  • 1
    That's what I was looking for. More specifically, the link to perlfunc for built-in functions.
    – Les
    Mar 1, 2021 at 19:04
3

Because atan2 is a builtin function, like sin or cos. Or print.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.