Contents /
Previous /
Next
System Interaction
Example:
system "ls -rt";
print $_;
System Interaction Functions
- 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: $cuser,
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".