POSIX
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 #define
s
in C, such as EINTR
or O_NDELAY
, are automatically exported into your namespace as constant functions. ...
Get Programming Perl, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.