- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

PERLIO

A space (or colon) separated list of PerlIO layers. If perl is built to use PerlIO system for IO (the default) these layers effect perl's IO.

It is conventional to start layer names with a colon e.g. :perlio to emphasise their similarity to variable "attributes". But the code that parses layer specification strings (which is also used to decode the PERLIO environment variable) treats the colon as a separator.

An unset or empty PERLIO is equivalent to the default set of layers for your platform, for example :unix:perlio on Unix-like systems and :unix:crlf on Windows and other DOS-like systems.

The list becomes the default for all perl's IO. Consequently only built-in layers can appear in this list, as external layers (such as :encoding()) need IO in order to load them!. See "open pragma" ("Perl pragma to set default PerlIO layers for input and output" (open) in the Perl Library Reference Manual (Volume 1)) for how to add external encodings as defaults.

The layers that it makes sense to include in the PERLIO environment variable are briefly summarised below. For more details see "$obj->SYSOPEN($path,$imode,$perm,[$fh])" (PerlIO) in the Perl Library Reference Manual (Volume 3).

:bytes
A pseudolayer that turns off the :utf8 flag for the layer below. Unlikely to be useful on its own in the global PERLIO environment variable. You perhaps were thinking of :crlf:bytes or :perlio:bytes.
:crlf
A layer which does CRLF to "\n" translation distinguishing "text" and "binary" files in the manner of MS-DOS and similar operating systems. (It currently does not mimic MS-DOS as far as treating of Control-Z as being an end-of-file marker.)
:mmap
A layer which implements "reading" of files by using mmap() to make (whole) file appear in the process's address space, and then using that as PerlIO's "buffer".
:perlio
This is a re-implementation of "stdio-like" buffering written as a PerlIO "layer". As such it will call whatever layer is below it for its operations (typically :unix).
:pop
An experimental pseudolayer that removes the topmost layer. Use with the same care as is reserved for nitroglycerin.
:raw
A pseudolayer that manipulates other layers. Applying the :raw layer is equivalent to calling binmode($fh). It makes the stream pass each byte as-is without any translation. In particular CRLF translation, and/or :utf8 intuited from locale are disabled. Unlike in the earlier versions of Perl :raw is not just the inverse of :crlf - other layers which would affect the binary nature of the stream are also removed or disabled.
:stdio
This layer provides PerlIO interface by wrapping system's ANSI C "stdio" library calls. The layer provides both buffering and IO. Note that :stdio layer does not do CRLF translation even if that is platforms normal behaviour. You will need a :crlf layer above it to do that.
:unix
Low level layer which calls read, write and lseek etc.
:utf8
A pseudolayer that turns on a flag on the layer below to tell perl that output should be in utf8 and that input should be regarded as already in valid utf8 form. It does not check for validity and as such should be handled with caution for input. Generally :encoding(utf8) is the best option when reading UTF-8 encoded data.
:win32
On Win32 platforms this experimental layer uses native "handle" IO rather than unix-like numeric file descriptor layer. Known to be buggy in this release.

On all platforms the default set of layers should give acceptable results.

For Unix platforms that will equivalent of "unix perlio" or "stdio". Configure is setup to prefer "stdio" implementation if system's library provides for fast access to the buffer, otherwise it uses the "unix perlio" implementation.

On Win32 the default in this release is "unix crlf". Win32's "stdio" has a number of bugs/mis-features for perl IO which are somewhat C compiler vendor/version dependent. Using our own crlf layer as the buffer avoids those issues and makes things more uniform. The crlf layer provides CRLF to/from "\n" conversion as well as buffering.

This release uses unix as the bottom layer on Win32 and so still uses C compiler's numeric file descriptor routines. There is an experimental native win32 layer which is expected to be enhanced and should eventually be the default under Win32.

The PERLIO environment variable is completely ignored when perl is run in taint mode.

ISBN 9781906966027Perl Language Reference ManualSee the print edition