You can use the sqrt function to find the positive square root. The square root is a number that becomes the original number when squared, and has positive and negative values. (Example:The square root of 4 is 2 and -2)
If you want a negative square root, just change the sign of the sqrt result.
my $root_num = sqrt $num;
This is an example to find the positive square root using the sqrt function.
use strict; use warnings; # Find the positive square root my $num = 16; my $root_num = sqrt $num;
If you want to know more about numerical calculations in Perl, please refer to the following articles.