NAME
POSIX::1003 - POSIX 1003.1 extensions to Perl
INHERITANCE
POSIX::1003 is extended by
POSIX::1003::Confstr
POSIX::1003::FdIO
POSIX::1003::FileSystem
POSIX::1003::Locale
POSIX::1003::Math
POSIX::1003::OS
POSIX::1003::Pathconf
POSIX::1003::Proc
POSIX::1003::Properties
POSIX::1003::Signals
POSIX::1003::Sysconf
POSIX::1003::Termios
POSIX::1003::Time
SYNOPSIS
# use the specific extensions
DESCRIPTION
The POSIX module in Core (distributed with Perl itself) is ancient, the documentation is usually wrong, and it has too much garbage in it. The POSIX::1003
tries to provide cleaner access to the Operating System. More about the choices in section "Rationale",
The POSIX standard is large, over 1200 functions; POSIX::Overview does list them all. The POSIX module in Core lists a small subset. This POSIX::1003
might get extended with additional functions itself.
Start looking in POSIX::Overview, to discover which module provides access to certain functionality. You may also guess from the module names, here below.
DETAILS
Modules in this distribution
- POSIX::1003::Confstr
-
Provide access to the
_CS_*
constants. - POSIX::1003::FdIO
-
Provides unbuffered IO handling; based on file-descriptors.
- POSIX::1003::FileSystem
-
Some generic file-system information. See also POSIX::1003::Pathconf for more precise info.
- POSIX::1003::Locale
-
Locales, see also perllocale.
- POSIX::1003::Math
-
Standard math functions of unknown precission.
- POSIX::1003::OS
-
A few ways to get Operating system information. See also POSIX::1003::Sysconf, POSIX::1003::Confstr, and POSIX::1003::Properties,
- POSIX::1003::Pathconf
-
Provide access to the
pathconf()
and its trillion_PC_*
constants. - POSIX::1003::Properties
-
Provide access to the
_POSIX_*
constants. - POSIX::1003::Signals
-
With helper modules POSIX::SigSet and POSIX::1003::SigAction.
- POSIX::1003::Sysconf
-
Provide access to the
sysconf
and its zillion_SC_*
constants. - POSIX::1003::Termios
-
Terminal IO
- POSIX::1003::Time
-
Time-stamp processing
Other modules
- Fcntl
-
Flags for modes, seek and fcntl are left to be defined by the Fcntl module.
- Errno
-
All constants representing error numbers are left to be defined in the Errno module.
- User::pwent
-
Provides an OO interface around
getpw*()
- User::grent
-
Provides an OO interface around
getgr*()
- Unix::SavedIDs
-
provides access to all
(get|set)e?[ug]id
functions. Of course, you may use the special variables$( $) $< $>
as well, but that gives unpredictable results.
Rationale
The POSIX module as distributed with Perl itself is ancient (it dates before Perl5) Although it proclaims that it provides access to all POSIX functions, it only lists about 200 out of 1200. From that subset, half of the functions with croak when you use them, complaining that they cannot get implemented in Perl for some reason.
Many other functions provided by POSIX-in-Core simply forward the caller to a function with the same name which is in basic perl (see perldoc). With a few serious complications: the functions in POSIX do not use prototypes, sometimes expect different arguments and sometimes return different values.
Back to the basics: the POSIX::1003 provides access to the POSIX libraries where they can be made compatible with Perl's way of doing things. For instance, setuid
of POSIX is implemented with $)
, whose exact behavior depends on compile-flags and OS: it's not the pure setuid()
of the standard hence left-out. There is no isalpha()
either: not compatible with Perl strings and implemented very different interface from POSIX. And there is also no own exit()
, because we have a CORE::exit()
with the same functionality.
POSIX::1003 compared to POSIX
This distribution does not add much functionality itself: it is mainly core's POSIX.xs (which is always available and ported to all platforms). You can access these routines via POSIX as well.
When you are used to POSIX.pm but want to move to POSIX::1003, you must be aware about the following differences:
- .
-
the constants and functions are spread over many separate modules, based on their purpose, where POSIX uses a header filename as tag to group provided functionality.
- .
-
functions provided by CORE are usually not exported again by POSIX::1003 (unless to avoid confusion, for instance: is
atan2()
in core or ::Math?) - .
-
constants which are already provided via Fcntl or Errno are not provided by this module as well. This should reduce the chance for confusion.
- .
-
functions which are also in CORE can be imported, but will silently be ignored. In
POSIX
, functions with the same name get exported without prototype, which does have consequences for interpretation of your program. This module uses prototypes on all exported functions, like CORE does. - .
-
an attempt is made to collect all
_SC_*
,_CS_*
,_PC_*
, and_POSIX_*
constants, not just a static subset. When an user program addresses a constant which is not defined by the system, POSIX will croak. Modules in POSIX::1003 on the other hand, will returnundef
.This simplifies code like this:
use POSIX::1003::FileSystem 'PATH_MAX'; use POSIX::1003::PathConfig '_PC_PATH_MAX'; my $max_fn = _PC_PATH_MAX($fn) // PATH_MAX // 1024;
With the tranditional POSIX, you have to
eval()
each use of a constant.
SEE ALSO
This module is part of POSIX-1003 distribution version 0.02, built on December 19, 2011. Website: http://perl.overmeer.net. The code is based on POSIX, which is released with Perl itself.
COPYRIGHTS
Copyrights of the perl code and the related documentation by 2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html