Edmund's Perl Quick Reference
MORE
INDEX

Formats

formline PICTURE, LIST
Formats LIST according to PICTURE and accumulates the result into $^A.
write [ FILEHANDLE ]
Writes a formatted record to the specified file, using the format associated with that file.

Formats are defined as follows:

    format [NAME] =
    FORMLIST
    .

FORMLIST pictures the lines, and contains the arguments which will give values to the fields in the lines. NAME defaults to STDOUT if omitted.

Picture fields are:

    @<<<... left adjusted field, repeat the < to denote the desired width
    @>>>... right adjusted field
    @|||... centered field
    @#.##...    numeric format with implied decimal point
    @* a multi-line field
Use ^ instead of @ for multiline block filling.
Use ~ at the beginning of a line to suppress unwanted empty lines.
Use ~~ at the beginning of a line to have this format line repeated until all fields are exhausted.
Use $- to zero to force a page break on the next write.
See also $^, $~, $^A, $^F, $- and $=

 

Directory Reading Routines

closedir DIRHANDLE
Closes a directory opened by opendir.
opendir DIRHANDLE, DIRNAME
Opens a directory on the handle specified.
readdir DIRHANDLE
Returns the next entry (or an array of entries) from the directory.
rewinddir DIRHANDLE
Positions the directory to the beginning.
seekdir DIRHANDLE, POS
Sets position for readdir on the directory.
telldir DIRHANDLE
Returns the position in the directory.

System Interaction

alarm EXPR
Schedules a SIGALRM to be delivered after EXPR seconds.
chdir [ EXPR ]
Changes the working directory. Uses $ENV{"HOME"} or $ENV{"LOGNAME"} if EXPR is omitted.
chroot FILENAME†
Changes the root directory for the process and its children.
die [ LIST ]
Prints the value of LIST to STDERR and exits with the current value of $! (errno). If $! is 0, exits with the value of ($? >> 8). If ($? >> 8) is 0, exits with 255. LIST defaults to "Died".
exec LIST
Executes the system command in LIST; does not return.
exit EXPR
Exits immediately with the value of EXPR, which defaults to 0 (zero). Calls END routines and object destructors before exiting.
fork
Does a fork(2) system call. Returns the process ID of the child to the parent process and zero to the child process.
getlogin
Returns the current login name as known by the system.
getpgrp [ PID ]
Returns the process group for process PID (0, or omitted, means the current process).
getppid
Returns the process ID of the parent process.
getpriority WHICH, WHO
Returns the current priority for a process, process group, or user.
glob PAT
Returns a list of filenames that match the shell pattern PAT.
kill LIST
Sends a signal to a list of processes. The first element of the list must be the signal to send (either numeric, or its name as a string).
setpgrp PID, PGRP
Sets the process group for the PID (0 means the current process).
setpriority WHICH, WHO, PRIORITY
Sets the current priority for a process, process group, or a user.
sleep [ EXPR ]
Causes the program to sleep for EXPR seconds, or forever if no EXPR. Returns the number of seconds actually slept.
syscall LIST
Calls the system call specified in the first element of the list, passing the rest of the list as arguments to the call.
system LIST
Does exactly the same thing as exec LIST except that a fork is performed first, and the parent process waits for the child process to complete.
times
Returns a 4-element array (0: $user, 1: $system, 2: $cursor, 3: $csystem) giving the user and system times, in seconds, for this process and the children of this process.
umask [ EXPR ]
Sets the umask for the process and returns the old one. If EXPR is omitted, returns current umask value.
wait
Waits for a child process to terminate and returns the process ID of the deceased process (-1 if none). The status is returned in $?.
waitpid PID, FLAGS
Performs the same function as the corresponding system call.
warn [ LIST ]
Prints the message on STDERR like die, but doesn't exit. LIST defaults to "Warning: something's wrong".