This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline.
[perl5.git] / lib / PerlIO.pm
CommitLineData
1141d9f8
NIS
1package PerlIO;
2
3# Map layer name to package that defines it
4my %alias = (encoding => 'Encode');
5
6sub import
7{
8 my $class = shift;
9 while (@_)
10 {
11 my $layer = shift;
12 if (exists $alias{$layer})
13 {
14 $layer = $alias{$layer}
15 }
16 else
17 {
18 $layer = "${class}::$layer";
19 }
20 eval "require $layer";
21 warn $@ if $@;
22 }
23}
24
251;
26__END__
b3d30bf7
NIS
27
28=head1 NAME
29
30PerlIO - On demand loader for PerlIO::* name space
31
32=head1 SYNOPSIS
33
34 open($fh,">:foo",...)
35
36=head1 DESCRIPTION
37
38When an undefined layer 'foo' is encountered in an C<open> or C<binmode> layer
39specification then C code performs the equivalent of:
40
41 use PerlIO 'foo';
42
43The perl code in PerlIO.pm then attempts to locate a layer by doing
44
45 require PerlIO::foo;
46
47Otherwise the C<PerlIO> package is a place holder for additional PerLIO related
48functions.
49
50
51=cut
52
53