open.pm
来自「MSYS在windows下模拟了一个类unix的终端」· PM 代码 · 共 77 行
PM
77 行
package open;$open::hint_bits = 0x20000;sub import { shift; die "`use open' needs explicit list of disciplines" unless @_; $^H |= $open::hint_bits; while (@_) { my $type = shift; if ($type =~ /^(IN|OUT)\z/s) { my $discp = shift; unless ($discp =~ /^\s*:(raw|crlf)\s*\z/s) { die "Unknown discipline '$discp'"; } $^H{"open_$type"} = $discp; } else { die "Unknown discipline class '$type'"; } }}1;__END__=head1 NAMEopen - perl pragma to set default disciplines for input and output=head1 SYNOPSIS use open IN => ":crlf", OUT => ":raw";=head1 DESCRIPTIONThe open pragma is used to declare one or more default disciplines forI/O operations. Any open() and readpipe() (aka qx//) operators foundwithin the lexical scope of this pragma will use the declared defaults.Neither open() with an explicit set of disciplines, nor sysopen() areinfluenced by this pragma.Only the two pseudo-disciplines ":raw" and ":crlf" are currentlyavailable.The ":raw" discipline corresponds to "binary mode" and the ":crlf"discipline corresponds to "text mode" on platforms that distinguishbetween the two modes when opening files (which is many DOS-likeplatforms, including Windows). These two disciplines are currentlyno-ops on platforms where binmode() is a no-op, but will besupported everywhere in future.=head1 UNIMPLEMENTED FUNCTIONALITYFull-fledged support for I/O disciplines is currently unimplemented.When they are eventually supported, this pragma will serve as one ofthe interfaces to declare default disciplines for all I/O.In future, any default disciplines declared by this pragma will beavailable by the special discipline name ":DEFAULT", and could be usedwithin handle constructors that allow disciplines to be specified.This would make it possible to stack new disciplines over the defaultones. open FH, "<:para :DEFAULT", $file or die "can't open $file: $!";Socket and directory handles will also support disciplines infuture.Full support for I/O disciplines will enable all of the supporteddisciplines to work on all platforms.=head1 SEE ALSOL<perlfunc/"binmode">, L<perlfunc/"open">, L<perlunicode>=cut
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?