D.6. Functions
The following tables detail the various default functions available in the Perl language.
D.6.1. Arithmetic Functions
Function | Use |
---|---|
abs expr | Returns the absolute value of expr. |
atan2 x,y | Returns the arctangent of x/y. |
cos expr | Returns the cosine of expr. |
exp expr | Returns e (the natural logarithm base) to the power of expr. |
int expr | Returns the integer portion of expr. |
log expr† | Returns 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 expr | Returns the sine of expr. |
sqrt expr | Returns the square root of expr. |
srand [ expr ] | Sets the random number seed for the rand operator. |
time | Returns the number of seconds since January 1, 1970. |
D.6.2. Conversion Functions
Function | Use |
---|---|
chr expr | Returns the character represented by the decimal value expr. |
gmtime expr | Returns 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 expr | Returns the decimal value of expr, with expr interpreted as a hex string. |
localtime expr | Returns 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 expr | Returns 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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.