* comment * This reference was adapted from the web page at: http://perldoc.perl.org/index-functions.html send comments, bug reports, requests to Emmanuel Florac * version * 1.3 * language * perl * comment * perl functions abs # abs VALUE absolute value function. accept # accept NEWSOCKET,GENERICSOCKET accept an incoming socket connect. alarm # alarm SECONDS schedule a SIGALRM. atan2 # atan2 Y,X arctangent of Y/X in the range -PI to PI. bind # bind SOCKET,NAME binds an address to a socket. binmode # binmode FILEHANDLE, LAYER # binmode FILEHANDLE prepare binary files for I/O. bless # bless REF,CLASSNAME # bless REF create an object. caller # caller EXPR returns context of the current subroutine call. chdir # chdir EXPR change the current working directory to EXPR or $ENV{HOME} if EXPR ommited. chmod # chmod LIST changes the permissions on a list of files. The first element of the list must be the numerical mode (usually octal). chomp # chomp VARIABLE # chomp( LIST ) # chomp remove a trailing record separator from a string or list of strings. chop # chop VARIABLE # chop( LIST ) # chop remove the last character from a string or a list of strings and returns the character chopped. If variable is a hash, chops the values, not the keys. chown # chown ( UID GID LIST ) change the owership on a list of files to UID and GID. -1 as a UID/GID leaves the value unchanged. returns the number of changed files. chr # chr NUMBER # chr get character this number represents in the character set. chroot # chroot DIRECTORY # chroot make directory new root for path lookups (you must be Root for that). close # close FILEHANDLE # close close file (or pipe or socket) handle. closedir # closedir DIRHANDLE close directory handle opened by opendir. connect # connect SOCKET,NAME connect to a remote socket. NAME should be a packed address of the appropriate type for the socket. continue # continue BLOCK optional trailing block in a while or foreach loop. Always executed. cos # cos EXPR # cos Returns the cosine of EXPR (expressed in radians). crypt # crypt PLAINTEXT,SALT one-way passwd-style encryption. When checking an encrypted string, use it as the salt. dbmclose * dbmclose HASH [This function has been largely superseded by the untie function.] Breaks the binding between a DBM file and a hash. dbmopen # dbmopen HASH,DBNAME,MASK [This function has been largely superseded by the tie function.] create binding on a tied dbm file (without the .dir or .pag extension). If the database doesn't exist, it's created with MASK access rights. defined # defined EXPR # defined test whether a value, variable, or function is defined. Use of defined on hashes and arrays is deprecated. delete # delete EXPR Given an expression that specifies a hash element, array element, hash slice, or array slice, deletes the specified element(s) from the hash or array. die # die LIST raise an exception or bail out, printing LIST to STDERR. do # do BLOCK Returns the value of the last command in the sequence of commands indicated by BLOCK. # do SUBROUTINE(LIST) A deprecated form of subroutine call. See perlsub. # do EXPR Uses the value of EXPR as a filename and executes the contents of the file as a Perl script. dump # dump LABEL # dump create an immediate core dump. each # each HASH retrieve the next key/value pair from a hash. endgrent be done using group file. endhostent be done using hosts file. endnetent be done using networks file. endprotoent be done using protocols file. endpwent be done using passwd file. endservent be done using services file. eof # eof FILEHANDLE # eof () # eof test a filehandle for its end, or if filehandle isn't open. eval # eval EXPR Run EXPR as a little perl program and returns its value. # eval BLOCK Execute BLOCK within the same perl program and trap exceptions. exec # exec LIST # exec PROGRAM LIST execute a program (with optional LIST parameters) and never returns. exists # exists EXPR test whether a hash key is present (even if undefined). exit # exit EXPR # exit Evaluates EXPR and exits immediately the program with that value, or 0 if EXPR is omitted. # exp EXPR # exp Returns e (the natural logarithm base) to the power of EXPR. fcntl # fcntl FILEHANDLE,FUNCTION,SCALAR file control system call fileno # fileno FILEHANDLE return file descriptor from filehandle. flock # flock FILEHANDLE,OPERATION lock an entire file with an advisory lock. fork # fork create a new process just like this one. format # format declare a picture format with use by the write() function. formline # formline PICTURE,LIST internal function used for formats. getc # getc FILEHANDLE # getc get the next character from the filehandle (STDIN if omitted). getgrent get next group record. getgrgid get group record given group user ID. getgrnam get group record given group name. gethostbyaddr get host record given its address. gethostbyname get host record given name. gethostent get next hosts record. getlogin # getlogin return who logged in at this tty. getnetbyaddr get network record given its address. getnetbyname get networks record given name. getnetent get next networks record. getpeername # getpeername SOCKET Returns the packed sockaddr address of other end of the SOCKET connection. getpgrp # getpgrp PID get process group for PID. Use PID 0 to get process group for the current process. getppid # getppid get parent process ID. getpriority # getpriority WHICH,WHO get current nice value. getprotobyname get protocol record given name. getprotobynumber get protocol record numeric protocol. getprotoent get next protocols record. getpwent get next passwd record. getpwnam # getpwnam NAME get passwd record given user login name. getpwuid get passwd record given user ID. getservbyname get services record given its name. getservbyport get services record given numeric port. getservent get next services record. getsockname # getsockname SOCKET retrieve packed sockaddr address of this end of the SOCKET connection. getsockopt # getsockopt SOCKET,LEVEL,OPTNAME get socket options on a given socket with a given LEVEL. glob # glob EXPR # glob expand filenames using wildcards. gmtime # gmtime EXPR convert UNIX time into record or string using Greenwich time. goto # goto LABEL # goto EXPR # goto &NAME create spaghetti code. grep # grep BLOCK LIST # grep EXPR,LIST locate elements in a list test true against a given criterion. hex # hex EXPR # hex convert a string to a hexadecimal number. import # import patch a module's namespace into your own. index # index STR,SUBSTR,POSITION # index STR,SUBSTR find a substring within a string starting from POSITION (or start if omitted). int # int EXPR # int get the integer portion of a number. ioctl # ioctl FILEHANDLE,FUNCTION,SCALAR system-dependent device control system call. join # join EXPR,LIST join a list into a string using EXPR separator and returns this string. keys # keys HASH Returns a list consisting of all the keys of the named hash. (In scalar context, returns the number of keys.) kill # kill SIGNAL, LIST send a signal to a process or a list of processes. last # last LABEL # last exit a block prematurely. lc # lc EXPR # lc return lower-case version of a string. lcfirst # lcfirst EXPR # lcfirst return a string with just the first letter in lower case. length # length EXPR # length return the number of characters in string EXPR. link # link OLDFILE,NEWFILE Creates a new filename linked to the old filename. listen # listen SOCKET,QUEUESIZE register your socket as a server. local # local EXPR create a temporary value for a global variable (dynamic scoping). localtime # localtime EXPR convert UNIX time into record or string using local time. lock # lock THING get a thread lock on a variable, subroutine, or method. log # log EXPR # log retrieve the natural logarithm for a number. lstat # lstat EXPR # lstat stat a symbolic link. m # m/REGEXP/ match a string with a regular expression pattern. map # map BLOCK LIST # map EXPR,LIST apply a change to a list to get back a new list with the changes. mkdir # mkdir FILENAME,MASK # mkdir FILENAME create a directory with MASK permissions. msgctl # msgctl ID,CMD,ARG SysV IPC message control operations. msgget # msgget KEY,FLAGS get SysV IPC message queue. msgrcv # msgrcv ID,VAR,SIZE,TYPE,FLAGS receive a SysV IPC message from a message queue. msgsnd # msgsnd ID,MSG,FLAGS send a SysV IPC message to a message queue. my # my EXPR # my TYPE EXPR # my EXPR : ATTRS # my TYPE EXPR : ATTRS declare and assign a local variable (lexical scoping). next # next LABEL # next it starts the next iteration of the loop. no # no Module VERSION LIST # no Module VERSION # no Module LIST # no Module unimport some module symbols or semantics at compile time. oct # oct EXPR # oct convert a string to an octal number. open # open FILEHANDLE,EXPR # open FILEHANDLE,MODE,EXPR # open FILEHANDLE,MODE,EXPR,LIST # open FILEHANDLE,MODE,REFERENCE # open FILEHANDLE Opens the file, pipe or command whose filename is given by EXPR, and associates it with FILEHANDLE. Also perl pragma to set default PerlIO layers for input and output. opendir # opendir DIRHANDLE,EXPR open a directory for processing by readdir, telldir, seekdir, rewinddir, and closedir. ord # ord EXPR # ord Returns a character's numeric representation. our # our EXPR # our EXPR TYPE # our EXPR : ATTRS # our TYPE EXPR : ATTRS declare and assign a package variable (lexical scoping). pack # pack TEMPLATE,LIST Takes a LIST of values and converts it into a string using the rules given by the TEMPLATE. package # package NAMESPACE # package declare a separate global namespace. pipe # pipe READHANDLE,WRITEHANDLE open a pair of connected filehandles. pop # pop ARRAY # pop remove the last element from an array and return it pos # pos SCALAR # pos find or set the offset for the last/next m//g search print # print FILEHANDLE LIST # print LIST # print output a string or a list of strings to a filehandle (or STDOUT if omitted). printf # printf FILEHANDLE FORMAT, LIST # printf FORMAT, LIST output a formatted list to a filehandle (or STDOUT if omitted). prototype # prototype FUNCTION get the prototype (if any) of a subroutine. push # push ARRAY,LIST append one or more elements to an array. q # q/STRING/ singly quote a string qq # qq/STRING/ doubly quote a string qr # qr/REGEXP/ Compile REGEXP pattern. quotemeta # quotemeta EXPR # quotemeta quote all non-word characters. qw # qw/STRING/ quote a list of words. qx # qx/STRING/ backquote quote a string. rand # rand EXPR # rand Returns a random fractional number greater than or equal to 0 and less than the value of EXPR. read # read FILEHANDLE,SCALAR,LENGTH,OFFSET # read FILEHANDLE,SCALAR,LENGTH Attempts to read LENGTH characters of data into variable SCALAR from the specified FILEHANDLE. Returns the number of characters actually read, 0 at end of file, or undef if there was an error. readdir # readdir DIRHANDLE Returns the next directory entry for a directory opened by opendir. If used in list context, returns all the rest of the entries in the directory. readline # readline EXPR fetch a record from the filehandle whose typeglob is contained in EXPR. readlink # readlink EXPR # readlink determine where a symbolic link is pointing. readpipe # readpipe EXPR execute EXPR as a system command and collect standard output. recv # recv SOCKET,SCALAR,LENGTH,FLAGS receive LENGTH characters of data into variable SCALAR from the specified SOCKET filehandle. redo # redo LABEL # redo Restarts the loop block without evaluating the conditional again. The continue block, if any, is not executed. ref # ref EXPR # ref Returns a non-empty string if EXPR is a reference, the empty string otherwise. rename # rename OLDNAME,NEWNAME change a filename. require # require VERSION Demands a version of perl specified by VERSION. # require EXPR # require load in external functions from a library at runtime. reset # reset EXPR # reset clear all variables of a given name. return # return EXPR # return Returns from a subroutine, eval, or do FILE with the value given in EXPR. reverse # reverse LIST In list context, returns a list value consisting of the elements of LIST in the opposite order. In scalar context, concatenates the elements of LIST and returns a string value with all characters in the opposite order. rewinddir # rewinddir DIRHANDLE Sets the current position to the beginning of the directory for the readdir routine on DIRHANDLE. rindex # rindex STR,SUBSTR,POSITION # rindex STR,SUBSTR right-to-left substring search, starting from end or POSITION. rmdir # rmdir FILENAME # rmdir remove a directory. s # s/STRING/REGEXP/OPTIONS substitute STRING with REGEXP. scalar # scalar EXPR force a scalar context. seek # seek FILEHANDLE,POSITION,WHENCE reposition file pointer for random-access I/O. WHENCE specifies if the new position is from start (0), current position (1) or end of file (2). seekdir # seekdir DIRHANDLE,POS reposition directory pointer. POS must be a value returned by telldir. select # select FILEHANDLE # select Returns the currently selected filehandle. Sets the current default filehandle for output, if FILEHANDLE is supplied. semctl # semctl ID,SEMNUM,CMD,ARG SysV semaphore control operations. semget # semget KEY,NSEMS,FLAGS get set of SysV semaphores. semop # semop KEY,OPSTRING SysV semaphore operations. send # send SOCKET,MSG,FLAGS,TO # send SOCKET,MSG,FLAGS send a message over a socket. setgrent prepare group file for use. sethostent prepare hosts file for use. setnetent prepare networks file for use. setpgrp # setpgrp PID,PGRP set the process group of a process. setpriority # setpriority WHICH,WHO,PRIORITY set a process's nice value. setprotoent prepare protocols file for use. setpwent prepare passwd file for use. setservent prepare services file for use. setsockopt # setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL set some socket options. shift # shift ARRAY # shift removes the first element of an array, and returns it. shmctl # shmctl ID,CMD,ARG SysV shared memory operations. shmget # shmget KEY,SIZE,FLAGS get SysV shared memory segment identifier. shmread # shmread ID,VAR,POS,SIZE read SysV shared memory. shmwrite write SysV shared memory. shutdown # shutdown SOCKET,HOW close down just half of a socket connection. sin # sin EXPR return the sine of a number in radians. sleep # sleep EXPR # sleep block for EXPR number of seconds or forever if EXPR omitted. socket # socket SOCKET,DOMAIN,TYPE,PROTOCOL create a socket. socketpair # socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL create a pair of sockets. sort # sort SUBNAME LIST # sort BLOCK LIST # sort LIST sort a list of values in list context. If SUBNAME is specified, it's a subroutine that returns an integer less than, equal to, or greater than 0 , depending on how the elements of the list are to be ordered. It's also a perl pragma to control sort() behaviour. splice # splice ARRAY,OFFSET,LENGTH,LIST # splice ARRAY,OFFSET,LENGTH # splice ARRAY,OFFSET # splice ARRAY Remove LENGTH elements from OFFSET in an array, and insert elements of LIST instead. split # split /PATTERN/,EXPR,LIMIT # split /PATTERN/,EXPR # split /PATTERN/ # split split up a string using a regexp PATTERN delimiter or whiltespace if omitted. sprintf # sprintf FORMAT, LIST Returns a formatted string. sqrt # sqrt EXPR # sqrt square root function. srand # srand EXPR # srand seed the random number generator. stat # stat FILEHANDLE # stat EXPR # stat Returns a 13-element list giving the status info for a file, either the file opened via FILEHANDLE, or named by EXPR. study # study SCALAR # study optimize input data for repeated searches. sub # sub NAME BLOCK # sub NAME (PROTO) BLOCK # sub NAME : ATTRS BLOCK # sub NAME (PROTO) : ATTRS BLOCK declare a subroutine, possibly anonymously. substr # substr EXPR,OFFSET,LENGTH,REPLACEMENT # substr EXPR,OFFSET,LENGTH # substr EXPR,OFFSET Extracts LENGTH (or all if omitted) characters from a string starting at OFFSET, and replaces them with REPLACEMENT if defined. symlink # symlink OLDFILE,NEWFILE create a symbolic link to a file. syscall # syscall NUMBER, LIST Calls the system call specified as the first element of the list, passing the remaining elements as arguments to the system call. sysopen # sysopen FILEHANDLE,FILENAME,MODE # sysopen FILEHANDLE,FILENAME,MODE,PERMS open a file, pipe, or descriptor and associates it with FILEHANDLE. sysread # sysread FLHNDLE,SCALAR,LENGTH,OFFSET # sysread FILEHANDLE,SCALAR,LENGTH Attempts to read LENGTH bytes of data into variable SCALAR from the specified FILEHANDLE. sysseek # sysseek FILEHANDLE,POSITION,WHENCE position I/O pointer on handle used with sysread and syswrite. system # system LIST # system PROGRAM LIST runs a separate program by forking it, and waits for the child process to complete. syswrite # syswrite FLHANDLE,SCALAR,LENGTH,OFFSET # syswrite FILEHANDLE,SCALAR,LENGTH # syswrite FILEHANDLE,SCALAR Attempts to write LENGTH bytes of data from variable SCALAR to the specified FILEHANDLE. tell # tell FILEHANDLE # tell Returns the current position in bytes for FILEHANDLE. telldir telldir DIRHANDLE Returns the current position of the readdir routines on DIRHANDLE. tie # tie VARIABLE,CLASSNAME,LIST This function binds a variable to a package class that will provide the implementation for the variable. VARIABLE is the name of the variable to be enchanted. CLASSNAME is the name of a class implementing objects of correct type. Any additional arguments are passed to the new method of the class. tied # tied VARIABLE Returns a reference to the object underlying VARIABLE. time # time return number of seconds since midnight, Jan 1, 1970. times # times Returns a four-element list giving the user and system times, in seconds, for this process and the children of this process. tr # tr/SEARCHLIST/REPLACEMENTLIST/cds transliterate all characters in SEARCHLIST with corresponding characters from REPLACEMENTLIST. truncate # truncate FILEHANDLE,LENGTH # truncate EXPR,LENGTH shorten a file to specified LENGTH. uc # uc EXPR # uc returns upper-case version of a string. ucfirst # ucfirst EXPR # ucfirst returns a string with just the first letter in upper case. umask # umask EXPR # umask set file creation mode mask and returns the previous value. undef # undef EXPR # undef removes a variable or function definition. unlink # unlink LIST # unlink removes one link to a file (deletes it). unpack # unpack TEMPLATE,EXPR converts a binary structure into a list of values. unshift # unshift ARRAY,LIST prepends LIST elements to the beginning of an ARRAY. untie # untie VARIABLE breaks a tie binding to a variable. use # use Module VERSION LIST # use Module VERSION # use Module LIST # use Module # use VERSION loads in a module at compile time, and demands a certain VERSION of perl. utime # utime LIST Changes the access and modification times on each file of a list of files. values # values HASH returns a list of the values in a hash. vec # vec EXPR,OFFSET,BITS tests or sets particular bits in a string. wait # wait waits for any child process to die. waitpid # waitpid PID,FLAGS wait for a particular child process to die. wantarray # wantarray Returns true if the context of the currently executing subroutine or eval() block is looking for a list value. warn # warn LIST Produces a message on STDERR just like die, but doesn't exit or throw an exception. write # write FILEHANDLE # write EXPR # write Writes a formatted record (possibly multi-line) to the specified FILEHANDLE, using the format associated with that file. -r # -r FILE Test if file is readable by effective uid/gid. -w # -w FILE Test if file is writable by effective uid/gid. -x # -x FILE Test if file is executable by effective uid/gid. -o # -o FILE Test if file is owned by effective uid. -R # -R FILE Test if file is readable by real uid/gid. -W # -W FILE Test if file is writable by real uid/gid. -X # -X FILE Test if file is executable by real uid/gid. -O # -O FILE Test if file is owned by real uid. -e # -e FILE Test if file exists. -z # -z FILE Test if file has zero size (is empty). -s # -s FILE Test if file has nonzero size (returns size in bytes). -f # -f FILE Test if file is a plain file. -d # -d FILE Test if file is a directory. -l # -l FILE Test if file is a symbolic link. -p # -p FILE Test if file is a named pipe (FIFO), or Test if filehandle is a pipe. -S # -S FILE Test if file is a socket. -b # -b FILE Test if file is a block special file. -c # -c FILE Test if file is a character special file. -t # -t FILE Test if filehandle is opened to a tty. -u # -u FILE Test if file has setuid bit set. -g # -g FILE Test if file has setgid bit set. -k # -k FILE Test if file has sticky bit set. -T # -T FILE Test if file is an ASCII text file (heuristic guess). -B # -B FILE Test if file is a "binary" file (opposite of -T). -M # -M FILE Script start time minus file modification time, in days. -A # -A FILE Script start time minus file access time, in days. -C # -C FILE Script start time minus inode change time (Unix, may differ for other platforms) y # y/SEARCHLIST/REPLACEMENTLIST/cds transliterate all characters in SEARCHLIST with corresponding characters from REPLACEMENTLIST. * comment * perl pragmas attributes get/set subroutine or variable attributes. attrs set/get attributes of a subroutine (deprecated). autouse postpone load of modules until a function is used. base Establish IS-A relationship with base classes at compile time. bigint Transparent BigInteger support for Perl. bignum Transparent BigNumber support for Perl. bigrat Transparent BigNumber/BigRational support for Perl. blib Use MakeMaker's uninstalled version of a package. bytes Perl pragma to force byte semantics rather than character semantics. charnames define character names for \N{named} string literal escapes. constant Perl pragma to declare constants. diagnostics produce verbose warning diagnostics. encoding allows you to write your script in non-ascii or non-utf8. fields compile-time class fields. filetest Perl pragma to control the filetest permission operators. if use a Perl module if a condition holds. integer Perl pragma to use integer arithmetic instead of floating point. less perl pragma to request less of something from the compiler. lib manipulate @INC at compile time. locale Perl pragma to use and avoid POSIX locales for built-in operations. ops Perl pragma to restrict unsafe operations when compiling. overload Package for overloading perl operations. re Perl pragma to alter regular expression behaviour. sigtrap Perl pragma to enable simple signal handling. strict Perl pragma to restrict unsafe constructs. subs Perl pragma to predeclare sub names. threads Perl extension allowing use of interpreter based threads from perl. threads::shared Perl extension for sharing data structures between threads. utf8 Perl pragma to enable/disable UTF-8 (or UTF-EBCDIC) in source code. vars Perl pragma to predeclare global variable names (obsolete). vmsish Perl pragma to control VMS-specific language features. warnings Perl pragma to control optional warnings. warnings::register warnings import function.