📄 ch31_15.htm
字号:
<html><head><title>use open (Programming Perl)</title><!-- STYLESHEET --><link rel="stylesheet" type="text/css" href="../style/style1.css"><!-- METADATA --><!--Dublin Core Metadata--><meta name="DC.Creator" content=""><meta name="DC.Date" content=""><meta name="DC.Format" content="text/xml" scheme="MIME"><meta name="DC.Generator" content="XSLT stylesheet, xt by James Clark"><meta name="DC.Identifier" content=""><meta name="DC.Language" content="en-US"><meta name="DC.Publisher" content="O'Reilly & Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="use open"><meta name="DC.Type" content="Text.Monograph"></head><body><!-- START OF BODY --><!-- TOP BANNER --><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home"><map name="banner-map"><AREA SHAPE="RECT" COORDS="0,0,466,71" HREF="index.htm" ALT="Programming Perl"><AREA SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"></map><!-- TOP NAV BAR --><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch31_14.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="ch31_01.htm">Chapter 31: Pragmatic Modules</a></td><td align="right" valign="top" width="172"><a href="ch31_16.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h2 class="sect1">31.15. use open</h2><blockquote><pre class="programlisting">use open IN => ":crlf", OUT => ":raw";</pre></blockquote><p>The <tt class="literal">open</tt> pragma declares one or more default disciplines for I/Ooperations. Any <tt class="literal">open</tt> and <tt class="literal">readpipe</tt> (that is, <tt class="literal">qx//</tt> orbackticks) operators found within the lexical scope of this pragma thatdo not specify their own disciplines will use the declared defaults.Neither <tt class="literal">open</tt> with an explicit set of disciplines, nor <tt class="literal">sysopen</tt>under any cirumstances, is influenced by this pragma.</p><p>Only the two disciplines <tt class="literal">:raw</tt> and <tt class="literal">:crlf</tt> are currentlyavailable (though as of this writing we expect a <tt class="literal">:utf8</tt> discipline tobe along shortly). On legacy systems that distinguish between thosetwo translation modes when opening files, the <tt class="literal">:raw</tt> disciplinecorresponds to "binary mode", and <tt class="literal">:crlf</tt> to "text mode". (These twodisciplines are currently no-ops on platforms where <tt class="literal">binmode</tt> is ano-op, but only for now; see the <tt class="literal">open</tt> function in <a href="ch29_01.htm">Chapter 29, "Functions"</a>,for a longer description of the semantics we expect ofvarious disciplines.)</p><p>Full-fledged support for I/O disciplines is currently unimplemented.When they are eventually supported, this pragma will serve as oneof the interfaces to declare default disciplines for all I/O. Atthat time, any default disciplines declared by this pragma will beavailable by the special discipline name ":DEFAULT" and usablewithin handle constructors that allow disciplines to be specified.This will make it possible to stack new disciplines over the defaultones.<blockquote><pre class="programlisting">open (FH, "<:para :DEFAULT", $file) or die "can't open $file: $!";</pre></blockquote>Once complete, full support for I/O disciplines will enable allsupported disciplines to work on all platforms.</p><!-- BOTTOM NAV BAR --><hr width="515" align="left"><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch31_14.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0"></a></td><td align="right" valign="top" width="172"><a href="ch31_16.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr><tr><td align="left" valign="top" width="172">31.14. use locale</td><td align="center" valign="top" width="171"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0"></a></td><td align="right" valign="top" width="172">31.16. use overload</td></tr></table></div><hr width="515" align="left"><!-- LIBRARY NAV BAR --><img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p><font size="-1"><a href="copyrght.htm">Copyright © 2001</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"> <area shape="rect" coords="2,-1,79,99" href="../index.htm"><area shape="rect" coords="84,1,157,108" href="../perlnut/index.htm"><area shape="rect" coords="162,2,248,125" href="../prog/index.htm"><area shape="rect" coords="253,2,326,130" href="../advprog/index.htm"><area shape="rect" coords="332,1,407,112" href="../cookbook/index.htm"><area shape="rect" coords="414,2,523,103" href="../sysadmin/index.htm"></map><!-- END OF BODY --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -