Functions fall into two major categories: list operators and named unary
operators. These differ in their precedence relationship with
a following comma.
List operators take more than one argument, while unary operators
can never take more than one argument. Thus, a comma terminates the
argument of a unary operator, but merely separates the arguments of
a list operator. A unary operator generally provides a scalar context
to its argument, while a list operator may provide either scalar and
list contexts for its arguments. If it does both, the scalar arguments
will be first, and the list argument will follow.
For instance, splice() has three
scalar arguments followed by a list.
List operators may consist of any
combination of scalar arguments or list values; the list values
will be included in the list as if each individual element were
interpolated at that point in the list, forming a longer single-dimensional
list value. Elements of the LIST should be separated by commas.
Any function in the list below may be used either with or without
parentheses around its arguments.
Remember the following rule:
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!
Each operator and function decides which sort of value it would
be most appropriate to return in a scalar context. Some operators
return the length of the list that would have been returned in a
list context. Some operators return the first value in the list.
Some operators return the last value in the list. Some operators
return a count of successful operations. In general, they do what
you want, unless you want consistency.
Perl Functions by Category
Here are Perl's functions (including things that look like functions,
like some of the keywords and named operators) arranged by category.
Some functions appear in more than one place.
Functions for SCALARs or strings
chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct,
ord, pack, q/STRING/, qq/STRING/, reverse, rindex, sprintf, substr,
tr///, uc, ucfirst, y///
Regular expressions and pattern matching
m//, pos, quotemeta, s///, split, study
Numeric functions
abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand
Functions for real @ARRAYs
pop, push, shift, splice, unshift
Functions for list data
grep, join, map, qw/STRING/, reverse, sort, unpack,
Functions for real %HASHes
delete, each, exists, keys, values,
Input and output functions
binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno,
flock, format, getc, print, printf, read, readdir, rewinddir,
seek, seekdir, select, syscall, sysread, sysseek, syswrite,
tell, telldir, truncate, warn, write
Functions for fixed length data or records
pack, read, syscall, sysread, syswrite, unpack, vec
Functions for filehandles, files, or directories
-X, chdir, chmod, chown, chroot, fcntl, glob, ioctl, link,
lstat, mkdir, open, opendir, readlink, rename, rmdir, stat,
symlink, umask, unlink, utime, -r, -w, -x, -o, -R, -W, -X,
-O, -e, -z, -s, -f, -d, -l, -p, -S, -b, -c, -t, -u, -g, -k,
-T, -B, -M, -A, -C,
Keywords related to the control flow of your perl program
caller, continue, die, do, dump, eval, exit, goto, last, next,
redo, return, sub, wantarray
Keywords related to scoping
caller, import, local, my, package, use
Miscellaneous functions
defined, dump, eval, formline, local, my, reset, scalar, undef, wantarray
Functions for processes and process groups
alarm, exec, fork, getpgrp, getppid, getpriority, kill,
pipe, qx/STRING/, setpgrp, setpriority, sleep, system,
times, wait, waitpid
Keywords related to perl modules
do, import, no, package, require, use
Keywords related to classes and object-orientedness
bless, dbmclose, dbmopen, package, ref, tie, tied, untie, use
Low-level socket functions
accept, bind, connect, getpeername, getsockname, getsockopt, listen,
recv, send, setsockopt, shutdown, socket, socketpair
System V interprocess communication functions
msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl,
shmget, shmread, shmwrite
Fetching user and group info
endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid,
getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent
Fetching network info
endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent,
getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber,
getprotoent, getservbyname, getservbyport, getservent, sethostent,
setnetent, setprotoent, setservent
Time-related functions
gmtime, localtime, time, times
Functions new in perl5
abs, bless, chomp, chr, exists, formline, glob, import, lc, lcfirst,
map, my, no, prototype, qx, qw, readline, readpipe, ref, sub*, sysopen,
tie, tied, uc, ucfirst, untie, use
* - sub was a keyword in perl4, but in perl5 it is an operator
which can be used in expressions.
Functions obsoleted in perl5
dbmclose, dbmopen,