### D.6. Functions

The following tables detail the various default functions available in the Perl language.

#### D.6.1. Arithmetic Functions

FunctionUse
abs exprReturns the absolute value of expr.
atan2 x,yReturns the arctangent of x/y.
cos exprReturns the cosine of expr.
exp exprReturns e (the natural logarithm base) to the power of expr.
int exprReturns the integer portion of expr.
log exprReturns the natural logarithm of expr.
rand [ expr ]Returns a random number between 0 and the value of expr. If expr is omitted, returns a value between 0 and 1.
sin exprReturns the sine of expr.
sqrt exprReturns the square root of expr.
srand [ expr ]Sets the random number seed for the rand operator.
timeReturns the number of seconds since January 1, 1970.

#### D.6.2. Conversion Functions

FunctionUse
chr exprReturns the character represented by the decimal value expr.
gmtime exprReturns a 9-element array (0 = \$sec, 1 = \$min, 2 = \$hour, 3 = \$mday, 4 = \$mon, 5 = \$year, 6 = \$wday, 7 = \$yday, 8 = \$isdst) with the time formatted for the Greenwich time zone. Note that expr should be in a form returned from a time function.
hex exprReturns the decimal value of expr, with expr interpreted as a hex string.
localtime exprReturns a 9-element array (0 = \$sec, 1 = \$min, 2 = \$hour, 3 = \$mday, 4 = \$mon, 5 = \$year, 6 = \$wday, 7 = \$yday, 8 = \$isdst) with the time formatted for the local time zone. Note that expr should be in a form returned from a time function.
oct exprReturns the decimal value of expr, with expr interpreted as an ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.