Perl built-in functions
(Redirected from built-in function (Perl))
Jump to navigation
Jump to search
Computing: Programming: Perl: built-in functions
This page is a seed article. You can help HTYP water it: make a request to expand a given page and/or donate to help give us more writing-hours!
|
By Type
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())
Dirs
- opendir(dirhandle, dirspec)
- rmdir
Dir Handles
- closedir
- readdir
- rewinddir
- seekdir
Files
- chdir
- chmod
- chown
- chroot
- link
- mkdir
- open(filehandle, filespec)
- readlink
- rename
File Handles
- binmode
- close
- eof
- flock
- getc
- lstat
- read
- seek
- truncate
- write
Numeric
- abs(number)
- exp
- log
- rand
- srand
- sqrt
Base conversion
- hex
- oct
Trigonometry
- atan2(Y, X) - returns the arctangent of Y/X
- cos
- sin
RegEx
- m/pattern/
- quotemeta
- s/pattern/replacement/egimosx
- tr/search_list/replace_list/cds
- y/search_list/replace_list/cds
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
conversion
- int
single-character
- chr(number) - returns the character whose ASCII code is number
- ord(string) - returns the ASCII code of the first character in string
Time
- gmtime
- localtime
- time
- times
Alphabetical
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
B
- bind()
- binmode(filehandle) - sets filehandle to be treated as binary
- bless()
C
- caller()
- chdir()
- chmod()
- chomp()
- chop()
- chown()
- chr()
- chroot()
- close()
- closedir()
- connect()
- cos()
- crypt()
D
- dbmclose()
- dbmopen()
- defined()
- delete()
- die()
- do subroutine
- dump()
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()
F
- fcntl()
- fileno()
- flock()
- fork
- format
- formline()
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()
H
- hex()
I
- index()
- int()
- ioctl()
J
- join()
K
- keys()
- kill()
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)
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}
N
- next
- no
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
P
- pack(template, list)
- pipe(readhandle, writehandle)
- pop(array)
- pos(scalar)
- print(filehandle, list)
- printf(filehandle, list)
- push(array, list)
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/
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