Perl built-in functions
From HTYP, the free directory anyone can edit
|
[edit] By Type
[edit] Arrays
- join(demarc,array) – joins array elements into one string, using demarc as a seperator string
- split(pattern,string,limit) – splits string into an array (return value) by dividing it wherever pattern is matched
- splice(target,offset,length,source) – combines parts of two arrays (replaces parts of target with source)
- pop(array) – remove/return the last element of array
- push(target,source) – adds elements from source to the end of the array target (opposite of pop())
- reverse(array) – returns an array containing the elements of the input array in reverse order
- sort(array) – returns an array containing the elements of the input array in sorted order
- shift(array) – remove/return the first element of array (opposite of unshift())
- unshift(target,source) – add elements from the array source to the beginning of the array target (opposite of shift())
[edit] Dirs
- opendir(dirhandle, dirspec)
- rmdir
[edit] Dir Handles
- closedir
- readdir
- rewinddir
- seekdir
[edit] Files
- chdir
- chmod
- chown
- chroot
- link
- mkdir
- open(filehandle, filespec)
- readlink
- rename
[edit] File Handles
- binmode
- close
- eof
- flock
- getc
- lstat
- read
- seek
- truncate
- write
[edit] Numeric
- abs(number)
- exp
- log
- rand
- srand
- sqrt
[edit] Base conversion
- hex
- oct
[edit] Trigonometry
- atan2(Y, X) - returns the arctangent of Y/X
- cos
- sin
[edit] RegEx
- m/pattern/
- quotemeta
- s/pattern/replacement/egimosx
- tr/search_list/replace_list/cds
- y/search_list/replace_list/cds
[edit] String
- chomp
- chop
- crypt
- index
- lc
- lcfirst
- length
- quotemeta
- rindex
- scalar
- substr(source,offset,len) – return len bytes from source after skipping offset characters
- uc
- ucfirst
- unpack
[edit] conversion
- int
[edit] single-character
- chr(number) - returns the character whose ASCII code is number
- ord(string) - returns the ASCII code of the first character in string
[edit] Time
- gmtime
- localtime
- time
- times
[edit] Alphabetical
[edit] A
- abs(arg) - returns absolute value of arg
- accept()
- alarm($seconds) - sends an alarm signal after $seconds seconds
- atan2($y,$x) - returns the arctangent of $y/$x
[edit] B
- bind()
- binmode(filehandle) - sets filehandle to be treated as binary
- bless()
[edit] C
- caller()
- chdir()
- chmod()
- chomp()
- chop()
- chown()
- chr()
- chroot()
- close()
- closedir()
- connect()
- cos()
- crypt()
[edit] D
- dbmclose()
- dbmopen()
- defined()
- delete()
- die()
- do subroutine
- dump()
[edit] E
- each()
- endgrent
- endhostent
- endnetent
- endprotoent
- endpwent
- endservent
- eof()
- eval()
- exec()
- exists($assoc($key)) - returns TRUE if $key exists within the hash $assoc. Doesn't work with dbm hashes.
- exit()
- exp()
[edit] F
- fcntl()
- fileno()
- flock()
- fork
- format
- formline()
[edit] G
- getc()
- getgrent
- getgrgid()
- getgrnam()
- gethostbyaddr()
- gethostbyname()
- gethostent
- getlogin
- getnetbyaddr()
- getnetbyname()
- getnetent
- getpeername()
- getpgrp()
- getppid
- getpriority()
- getprotobyname()
- getprotobynumber()
- getprotoent
- getpwent
- getpwnam()
- getpwuid()
- getserverbyname()
- getserverbyport()
- getservent
- getsockname()
- getsockopt()
- glob()
- gmtime()
- goto()
- grep()
[edit] H
- hex()
[edit] I
- index()
- int()
- ioctl()
[edit] J
- join()
[edit] K
- keys()
- kill()
[edit] L
- last()
- lc(string) - returns string in lowercase
- lcfirst(string) - returns string with first character lowercased
- length(string) - returns length (number of characters in) string
- link(oldfile,newfile) - creates newfile as a link to oldfile
- listen(socket,queuesize) - waits for incoming events on a socket
- local(variable list) - makes all variables in variable list local to the current subroutine
- localtime(number) - converts the binary time stored in number to a 9-element list and localizes it to the machine's timezone
- log(number) - returns the natural logarithm (i.e. loge) of number
- lstat(fileHandle) - returns file statistics for the file opened with file handle fileHandle (does not de-reference symbolic links)
[edit] M
- m/pattern/gimosx - performs pattern-matching; other characters may be used as delimiters instead of "/". See Perl regex
- map(expr,list) - returns an array containing the output of expr(list item) for each item in list
- mkdir(name,mode) - creates a directory named name (can be relative or absolute filespec), with the file attributes in mode. See mkdir for related information.
- msgctl
- msgget
- msgrcv
- msgsnd
- my(variable list) - makes all variables in variable list local to the current {block}
[edit] N
- next
- no
[edit] O
- oct(string) - converts string from octal to decimal
- open(fileHandle, name) - opens a file named name and associates it with fileHandle
- opendir(dirHandle, name) - opens a directory named name and associates it with dirHandle
- ord(string) - returns the ASCII code of the first character in string, as an integer
[edit] P
- pack(template, list)
- pipe(readhandle, writehandle)
- pop(array)
- pos(scalar)
- print(filehandle, list)
- printf(filehandle, list)
- push(array, list)
[edit] Q
- q/string/
- qq/string/
- quotemeta(string) - prepares a string for use in a regex by backslashing any characters with special meanings
- qw/string/
- qx/string/
[edit] R
- rand(number) - returns a random number between 0 and number
- read(filehandle, scalar, length)
- readdir
- readlink
- recv
- redo
- ref
- rename(oldname, newname) - renames file oldname to newname
- require(filename) - executes the Perl code inside file filename (if no path specified, searches Perl path)
- reset
- return
- reverse(list) - reverses the sorting of array list
- rewinddir
- rindex(string, substring) - returns the position of the last occurrence of substring in string
- rmdir

