perl5004delta.html

来自「perl教程」· HTML 代码 · 共 1,154 行 · 第 1/5 页

HTML
1,154 行
字号

<dd>
<p>Perl memory allocation is by bucket with sizes close to powers of two.
Because of these malloc overhead may be big, especially for data of
size exactly a power of two.  If <code>PACK_MALLOC</code> is defined, perl uses
a slightly different algorithm for small allocations (up to 64 bytes
long), which makes it possible to have overhead down to 1 byte for
allocations which are powers of two (and appear quite often).</p>
</dd>
<dd>
<p>Expected memory savings (with 8-byte alignment in <code>alignbytes</code>) is
about 20% for typical Perl usage.  Expected slowdown due to additional
malloc overhead is in fractions of a percent (hard to measure, because
of the effect of saved memory on speed).</p>
</dd>
</li>
<dt><strong><a name="item__2ddtwo_pot_optimize">-DTWO_POT_OPTIMIZE</a></strong>

<dd>
<p>Similarly to <code>PACK_MALLOC</code>, this macro improves allocations of data
with size close to a power of two; but this works for big allocations
(starting with 16K by default).  Such allocations are typical for big
hashes and special-purpose scripts, especially image processing.</p>
</dd>
<dd>
<p>On recent systems, the fact that perl requires 2M from system for 1M
allocation will not affect speed of execution, since the tail of such
a chunk is not going to be touched (and thus will not require real
memory).  However, it may result in a premature out-of-memory error.
So if you will be manipulating very large blocks with sizes close to
powers of two, it would be wise to define this macro.</p>
</dd>
<dd>
<p>Expected saving of memory is 0-100% (100% in applications which
require most memory in such 2**n chunks); expected slowdown is
negligible.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="miscellaneous_efficiency_enhancements">Miscellaneous efficiency enhancements</a></h2>
<p>Functions that have an empty prototype and that do nothing but return
a fixed value are now inlined (e.g. <code>sub PI () { 3.14159 }</code>).</p>
<p>Each unique hash key is only allocated once, no matter how many hashes
have an entry with that key.  So even if you have 100 copies of the
same hash, the hash keys never have to be reallocated.</p>
<p>
</p>
<hr />
<h1><a name="support_for_more_operating_systems">Support for More Operating Systems</a></h1>
<p>Support for the following operating systems is new in Perl 5.004.</p>
<p>
</p>
<h2><a name="win32">Win32</a></h2>
<p>Perl 5.004 now includes support for building a &quot;native&quot; perl under
Windows NT, using the Microsoft Visual C++ compiler (versions 2.0
and above) or the Borland C++ compiler (versions 5.02 and above).
The resulting perl can be used under Windows 95 (if it
is installed in the same directory locations as it got installed
in Windows NT).  This port includes support for perl extension
building tools like <a href="../../lib/ExtUtils/MakeMaker.html">the MakeMaker manpage</a> and <em>h2xs</em>, so that many extensions
available on the Comprehensive Perl Archive Network (CPAN) can now be
readily built under Windows NT.  See <a href="http://www.perl.com/">http://www.perl.com/</a> for more
information on CPAN and <em>README.win32</em> in the perl distribution for more
details on how to get started with building this port.</p>
<p>There is also support for building perl under the Cygwin32 environment.
Cygwin32 is a set of GNU tools that make it possible to compile and run
many Unix programs under Windows NT by providing a mostly Unix-like 
interface for compilation and execution.  See <em>README.cygwin32</em> in the
perl distribution for more details on this port and how to obtain the
Cygwin32 toolkit.</p>
<p>
</p>
<h2><a name="plan_9">Plan 9</a></h2>
<p>See <em>README.plan9</em> in the perl distribution.</p>
<p>
</p>
<h2><a name="qnx">QNX</a></h2>
<p>See <em>README.qnx</em> in the perl distribution.</p>
<p>
</p>
<h2><a name="amigaos">AmigaOS</a></h2>
<p>See <em>README.amigaos</em> in the perl distribution.</p>
<p>
</p>
<hr />
<h1><a name="pragmata">Pragmata</a></h1>
<p>Six new pragmatic modules exist:</p>
<dl>
<dt><strong><a name="item_qw">use autouse MODULE =&gt; qw(sub1 sub2 sub3)</a></strong>

<dd>
<p>Defers <a href="../../lib/Pod/perlfunc.html#item_require"><code>require MODULE</code></a> until someone calls one of the specified
subroutines (which must be exported by MODULE).  This pragma should be
used with caution, and only when necessary.</p>
</dd>
</li>
<dt><strong><a name="item_use_blib">use blib</a></strong>

<dt><strong><a name="item_use_blib__27dir_27">use blib 'dir'</a></strong>

<dd>
<p>Looks for MakeMaker-like <em>'blib'</em> directory structure starting in
<em>dir</em> (or current directory) and working back up to five levels of
parent directories.</p>
</dd>
<dd>
<p>Intended for use on command line with <strong>-M</strong> option as a way of testing
arbitrary scripts against an uninstalled version of a package.</p>
</dd>
</li>
<dt><strong><a name="item_use_constant_name__3d_3e_value">use constant NAME =&gt; VALUE</a></strong>

<dd>
<p>Provides a convenient interface for creating compile-time constants,
See <a href="../../lib/Pod/perlsub.html#constant_functions">Constant Functions in the perlsub manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_use_locale">use locale</a></strong>

<dd>
<p>Tells the compiler to enable (or disable) the use of POSIX locales for
builtin operations.</p>
</dd>
<dd>
<p>When <a href="#item_use_locale"><code>use locale</code></a> is in effect, the current LC_CTYPE locale is used
for regular expressions and case mapping; LC_COLLATE for string
ordering; and LC_NUMERIC for numeric formatting in printf and sprintf
(but <strong>not</strong> in print).  LC_NUMERIC is always used in write, since
lexical scoping of formats is problematic at best.</p>
</dd>
<dd>
<p>Each <a href="#item_use_locale"><code>use locale</code></a> or <code>no locale</code> affects statements to the end of
the enclosing BLOCK or, if not inside a BLOCK, to the end of the
current file.  Locales can be switched and queried with
POSIX::setlocale().</p>
</dd>
<dd>
<p>See <a href="../../lib/Pod/perllocale.html">the perllocale manpage</a> for more information.</p>
</dd>
</li>
<dt><strong><a name="item_use_ops">use ops</a></strong>

<dd>
<p>Disable unsafe opcodes, or any named opcodes, when compiling Perl code.</p>
</dd>
</li>
<dt><strong><a name="item_use_vmsish">use vmsish</a></strong>

<dd>
<p>Enable VMS-specific language features.  Currently, there are three
VMS-specific features available: 'status', which makes <a href="../../lib/Pod/perlvar.html#item__"><code>$?</code></a> and
<a href="../../lib/Pod/perlfunc.html#item_system"><code>system</code></a> return genuine VMS status values instead of emulating POSIX;
'exit', which makes <a href="../../lib/Pod/perlfunc.html#item_exit"><code>exit</code></a> take a genuine VMS status value instead of
assuming that <code>exit 1</code> is an error; and 'time', which makes all times
relative to the local time zone, in the VMS tradition.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="modules">Modules</a></h1>
<p>
</p>
<h2><a name="required_updates">Required Updates</a></h2>
<p>Though Perl 5.004 is compatible with almost all modules that work
with Perl 5.003, there are a few exceptions:</p>
<pre>
    Module   Required Version for Perl 5.004
    ------   -------------------------------
    Filter   Filter-1.12
    LWP      libwww-perl-5.08
    Tk       Tk400.202 (-w makes noise)</pre>
<p>Also, the majordomo mailing list program, version 1.94.1, doesn't work
with Perl 5.004 (nor with perl 4), because it executes an invalid
regular expression.  This bug is fixed in majordomo version 1.94.2.</p>
<p>
</p>
<h2><a name="installation_directories">Installation directories</a></h2>
<p>The <em>installperl</em> script now places the Perl source files for
extensions in the architecture-specific library directory, which is
where the shared libraries for extensions have always been.  This
change is intended to allow administrators to keep the Perl 5.004
library directory unchanged from a previous version, without running
the risk of binary incompatibility between extensions' Perl source and
shared libraries.</p>
<p>
</p>
<h2><a name="module_information_summary">Module information summary</a></h2>
<p>Brand new modules, arranged by topic rather than strictly
alphabetically:</p>
<pre>
    CGI.pm               Web server interface (&quot;Common Gateway Interface&quot;)
    CGI/Apache.pm        Support for Apache's Perl module
    CGI/Carp.pm          Log server errors with helpful context
    CGI/Fast.pm          Support for FastCGI (persistent server process)
    CGI/Push.pm          Support for server push
    CGI/Switch.pm        Simple interface for multiple server types</pre>
<pre>
    CPAN                 Interface to Comprehensive Perl Archive Network
    CPAN::FirstTime      Utility for creating CPAN configuration file
    CPAN::Nox            Runs CPAN while avoiding compiled extensions</pre>
<pre>
    IO.pm                Top-level interface to IO::* classes
    IO/File.pm           IO::File extension Perl module
    IO/Handle.pm         IO::Handle extension Perl module
    IO/Pipe.pm           IO::Pipe extension Perl module
    IO/Seekable.pm       IO::Seekable extension Perl module
    IO/Select.pm         IO::Select extension Perl module
    IO/Socket.pm         IO::Socket extension Perl module</pre>
<pre>
    Opcode.pm            Disable named opcodes when compiling Perl code</pre>
<pre>
    ExtUtils/Embed.pm    Utilities for embedding Perl in C programs
    ExtUtils/testlib.pm  Fixes up @INC to use just-built extension</pre>
<pre>
    FindBin.pm           Find path of currently executing program</pre>
<pre>
    <span class="variable">Class</span><span class="operator">/</span><span class="variable">Struct</span><span class="operator">.</span><span class="variable">pm</span>      <span class="variable">Declare</span> <span class="variable">struct</span><span class="operator">-</span><span class="variable">like</span> <span class="variable">datatypes</span> <span class="variable">as</span> <span class="variable">Perl</span> <span class="variable">classes</span>
    <span class="variable">File</span><span class="operator">/</span><span class="keyword">stat</span><span class="operator">.</span><span class="variable">pm</span>         <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="keyword">stat</span>
    <span class="variable">Net</span><span class="operator">/</span><span class="variable">hostent</span><span class="operator">.</span><span class="variable">pm</span>       <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="variable">gethost</span><span class="operator">*</span>
    <span class="variable">Net</span><span class="operator">/</span><span class="variable">netent</span><span class="operator">.</span><span class="variable">pm</span>        <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="variable">getnet</span><span class="operator">*</span>
    <span class="variable">Net</span><span class="operator">/</span><span class="variable">protoent</span><span class="operator">.</span><span class="variable">pm</span>      <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="variable">getproto</span><span class="operator">*</span>
    <span class="variable">Net</span><span class="operator">/</span><span class="variable">servent</span><span class="operator">.</span><span class="variable">pm</span>       <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="variable">getserv</span><span class="operator">*</span>
    <span class="variable">Time</span><span class="operator">/</span><span class="keyword">gmtime</span><span class="operator">.</span><span class="variable">pm</span>       <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="keyword">gmtime</span>
    <span class="variable">Time</span><span class="operator">/</span><span class="keyword">localtime</span><span class="operator">.</span><span class="variable">pm</span>    <span class="variable">By</span><span class="operator">-</span><span class="variable">name</span> <span class="variable">interface</span> <span class="variable">to</span> <span class="variable">Perl's</span> <span class="variable">builtin</span> <span class="keyword">localtime</span>
    <span class="variable">Time</span><span class="operator">/</span><span class="variable">tm</span><span class="operator">.</span><span class="variable">pm</span>           <span class="variable">Internal</span> <span class="variable">object</span> <span class="keyword">for</span> <span class="variable">Time:</span>:{<span class="variable">gm</span><span class="operator">,</span><span class="keyword">local</span><span class="operator">}</span><span class="keyword">time</span>
    <span class="variable">User</span><span class="operator">/</span><span class="variable">grent</span><span class="operator">.</span><span class="variable">pm</span>        <span class="variable">By</span><span class="operator">-</span><span class="var

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?