PERLIO=stdio ./perl harness
PERLIO=perlio ./perl harness
+For the various value of PERLIO see L<perlrun/PERLIO>.
+
=head2 Querying the layers of filehandle
The following returns the B<names> of the PerlIO layers on a filehandle.
C<unix>) is not part of the stack, but under C<perlio> (and the
experimental C<mmap>) it is.
-In platforms of DOS progeny (Win32 being the most prominent) the
-lowest level layers are C<unix crlf>, meaning that Perl first uses the
-UNIX-style low-level fd layer, and then on top of that a layer that
-handles the CRLF translation.
-
The following table summarizes the default layers on UNIX-like and
DOS-like platforms and depending on the setting of the C<$ENV{PERLIO}>:
- PERLIO UNIX-like DOS-like
+ PERLIO UNIX-like DOS-like
- none stdio unix crlf
- stdio stdio stdio
- perlio unix perlio unix perlio
- mmap unix mmap unix mmap
+ none or "" stdio unix crlf
+ stdio stdio stdio
+ perlio unix perlio unix perlio
+ mmap unix mmap unix mmap
By default the layers from the input side of the filehandle is
returned, to get the output side use the optional C<output> argument:
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 C<:stdio>.
+
The list becomes the default for I<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 L<"open pragma"|open> for how to add external
print "1..0 # Skip: not perlio\n";
exit 0;
}
+ # Makes testing easier.
+ $ENV{PERLIO} = 'stdio' if exists $ENV{PERLIO} && $ENV{PERLIO} eq '';
if (exists $ENV{PERLIO} && $ENV{PERLIO} !~ /^(stdio|perlio|mmap)$/) {
+ # We are not prepared for anything else.
print "1..0 # PERLIO='$ENV{PERLIO}' unknown\n";
exit 0;
}
sub check {
my ($result, $expected, $id) = @_;
+ # An interesting dance follows where we try to make the following
+ # IO layer stack setups to compare equal:
+ #
+ # PERLIO UNIX-like DOS-like
+ #
+ # none or "" stdio unix crlf
+ # stdio stdio stdio
+ # perlio unix perlio unix perlio
+ # mmap unix mmap unix mmap
+ #
if ($NONSTDIO) {
# Get rid of "unix".
shift @$result if $result->[0] eq "unix";