What is abs() in Perl?
The abs() function returns the absolute value of a number.
Figure 1 shows the mathematical representation of the abs() function.
Syntax
abs(num)
numis the number whose absolute value is required
Parameter
The abs() function takes a number as a parameter.
Return value
The abs() function returns the absolute value of a number passed as a parameter.
If a
stringis passed to this function it returns0.
Code
#positive numberprint "The value of abs(10) : ".abs(10). "\n";#zeroprint "The value of abs(0) : ".abs(0). "\n";#negative numberprint "The value of abs(-10) : ".abs(-10). "\n";#stringprint "The value of abs(str) : ".abs("str"). "\n";