Commit | Line | Data |
---|---|---|
1141d9f8 NIS |
1 | package PerlIO; |
2 | ||
3 | # Map layer name to package that defines it | |
4 | my %alias = (encoding => 'Encode'); | |
5 | ||
6 | sub 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 | ||
25 | 1; | |
26 | __END__ | |
b3d30bf7 NIS |
27 | |
28 | =head1 NAME | |
29 | ||
30 | PerlIO - On demand loader for PerlIO::* name space | |
31 | ||
32 | =head1 SYNOPSIS | |
33 | ||
34 | open($fh,">:foo",...) | |
35 | ||
36 | =head1 DESCRIPTION | |
37 | ||
38 | When an undefined layer 'foo' is encountered in an C<open> or C<binmode> layer | |
39 | specification then C code performs the equivalent of: | |
40 | ||
41 | use PerlIO 'foo'; | |
42 | ||
43 | The perl code in PerlIO.pm then attempts to locate a layer by doing | |
44 | ||
45 | require PerlIO::foo; | |
46 | ||
47 | Otherwise the C<PerlIO> package is a place holder for additional PerLIO related | |
48 | functions. | |
49 | ||
50 | ||
51 | =cut | |
52 | ||
53 |