July 2000
Intermediate to advanced
1104 pages
35h 1m
English
use POSIX;
# Round floats up or down to nearest integer.
$n = ceil($n); # round up
$n = floor($n); # round down
# Produces "2000-04-01" for today.
$datestr = strftime("%Y-%m-%d", localtime);
# Produces "Saturday 04/01/00" for same date.
$datestr = strftime("%A %D", localtime);
# Try new temporary filenames until we get one
# that didn't already exist; see also File::Temp
# on CPAN, or in v5.6.1.
do {
$name = tmpnam();
} until sysopen(FH, $name, O_CREAT|O_EXCL|O_RDWR, 0666);
# Check for whether system has insecure chown giveaway.
if (sysconf(_PC_CHOWN_RESTRICTED)) {
print "Hurray -- only the superuser may call chown\n";
}
# Find current system's uname info.
my($kernel, $hostname, $release, $version, $hardware) = uname();
use POSIX ":sys_wait_h";
while (($dead_pid = waitpid(-1, &WNOHANG)) > 0) {
# Do something with $dead_pid if you want.
}
# Become new session/process-group leader (needed to create daemons
# unaffected by keyboard signals or exiting login shells).
setsid(0) or die "setsid failed: $!";Perl's POSIX module permits you to access all
(or nearly all) the standard POSIX 1003.1 identifiers, plus a few more
from ANSI C that we didn't know where else to put. This module
provides more functions than any other. See its online documentation
for the gory details or the POSIX Programmer's
Guide, by Donald Lewine (O'Reilly, 1991).
Identifiers that are parameterless #defines
in C, such as EINTR or O_NDELAY, are automatically exported into your namespace as constant functions. ...