2 $open::hint_bits = 0x20000;
6 die "`use open' needs explicit list of disciplines" unless @_;
7 $^H |= $open::hint_bits;
10 if ($type =~ /^(IN|OUT)\z/s) {
12 unless ($discp =~ /^\s*:(raw|crlf)\s*\z/s) {
13 die "Unknown discipline '$discp'";
15 $^H{"open_$type"} = $discp;
18 die "Unknown discipline class '$type'";
28 open - perl pragma to set default disciplines for input and output
32 use open IN => ":crlf", OUT => ":raw";
36 The open pragma is used to declare one or more default disciplines for
37 I/O operations. Any open() and readpipe() (aka qx//) operators found
38 within the lexical scope of this pragma will use the declared defaults.
39 Neither open() with an explicit set of disciplines, nor sysopen() are
40 influenced by this pragma.
42 Only the two pseudo-disciplines ":raw" and ":crlf" are currently
45 The ":raw" discipline corresponds to "binary mode" and the ":crlf"
46 discipline corresponds to "text mode" on platforms that distinguish
47 between the two modes when opening files (which is many DOS-like
48 platforms, including Windows). These two disciplines are currently
49 no-ops on platforms where binmode() is a no-op, but will be
50 supported everywhere in future.
52 =head1 UNIMPLEMENTED FUNCTIONALITY
54 Full-fledged support for I/O disciplines is currently unimplemented.
55 When they are eventually supported, this pragma will serve as one of
56 the interfaces to declare default disciplines for all I/O.
58 In future, any default disciplines declared by this pragma will be
59 available by the special discipline name ":DEFAULT", and could be used
60 within handle constructors that allow disciplines to be specified.
61 This would make it possible to stack new disciplines over the default
64 open FH, "<:para :DEFAULT", $file or die "can't open $file: $!";
66 Socket and directory handles will also support disciplines in
69 Full support for I/O disciplines will enable all of the supported
70 disciplines to work on all platforms.
74 L<perlfunc/"binmode">, L<perlfunc/"open">, L<perlunicode>