perl5005delta.html

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

HTML
1,169 行
字号
<p>
</p>
<h2><a name="foreach__1__1000000__optimized"><code>foreach (1..1000000)</code> optimized</a></h2>
<p><code>foreach (1..1000000)</code> is now optimized into a counting loop.  It does
not try to allocate a 1000000-size list anymore.</p>
<p>
</p>
<h2><a name="foo___can_be_used_as_implicitly_quoted_package_name"><code>Foo::</code> can be used as implicitly quoted package name</a></h2>
<p>Barewords caused unintuitive behavior when a subroutine with the same
name as a package happened to be defined.  Thus, <code>new Foo @args</code>,
use the result of the call to <code>Foo()</code> instead of <code>Foo</code> being treated
as a literal.  The recommended way to write barewords in the indirect
object slot is <code>new Foo:: @args</code>.  Note that the method <code>new()</code> is
called with a first argument of <code>Foo</code>, not <code>Foo::</code> when you do that.</p>
<p>
</p>
<h2><a name="exists__foo___bar____tests_existence_of_a_package"><code>exists $Foo::{Bar::}</code> tests existence of a package</a></h2>
<p>It was impossible to test for the existence of a package without
actually creating it before.  Now <code>exists $Foo::{Bar::}</code> can be
used to test if the <code>Foo::Bar</code> namespace has been created.</p>
<p>
</p>
<h2><a name="better_locale_support">Better locale support</a></h2>
<p>See <a href="../../lib/Pod/perllocale.html">the perllocale manpage</a>.</p>
<p>
</p>
<h2><a name="experimental_support_for_64bit_platforms">Experimental support for 64-bit platforms</a></h2>
<p>Perl5 has always had 64-bit support on systems with 64-bit longs.
Starting with 5.005, the beginnings of experimental support for systems
with 32-bit long and 64-bit 'long long' integers has been added.
If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
define it in perl.h) then perl will be built with 'long long' support.
There will be many compiler warnings, and the resultant perl may not
work on all systems.  There are many other issues related to
third-party extensions and libraries.  This option exists to allow
people to work on those issues.</p>
<p>
</p>
<h2><a name="prototype___returns_useful_results_on_builtins"><a href="../../lib/Pod/perlfunc.html#item_prototype"><code>prototype()</code></a> returns useful results on builtins</a></h2>
<p>See <a href="../../lib/Pod/perlfunc.html#prototype">prototype in the perlfunc manpage</a>.</p>
<p>
</p>
<h2><a name="extended_support_for_exception_handling">Extended support for exception handling</a></h2>
<p><a href="../../lib/Pod/perlfunc.html#item_die"><code>die()</code></a> now accepts a reference value, and <a href="../../lib/Pod/perlvar.html#item___"><code>$@</code></a> gets set to that
value in exception traps.  This makes it possible to propagate
exception objects.  This is an undocumented <strong>experimental</strong> feature.</p>
<p>
</p>
<h2><a name="reblessing_in_destroy___supported_for_chaining_destroy___methods">Re-blessing in <code>DESTROY()</code> supported for chaining <code>DESTROY()</code> methods</a></h2>
<p>See <a href="../../lib/Pod/perlobj.html#destructors">Destructors in the perlobj manpage</a>.</p>
<p>
</p>
<h2><a name="all_printf_format_conversions_are_handled_internally">All <a href="../../lib/Pod/perlfunc.html#item_printf"><code>printf</code></a> format conversions are handled internally</a></h2>
<p>See <a href="../../lib/Pod/perlfunc.html#printf">printf in the perlfunc manpage</a>.</p>
<p>
</p>
<h2><a name="new_init_keyword">New <code>INIT</code> keyword</a></h2>
<p><code>INIT</code> subs are like <code>BEGIN</code> and <code>END</code>, but they get run just before
the perl runtime begins execution.  e.g., the Perl Compiler makes use of
<code>INIT</code> blocks to initialize and resolve pointers to XSUBs.</p>
<p>
</p>
<h2><a name="new_lock_keyword">New <a href="../../lib/Pod/perlfunc.html#item_lock"><code>lock</code></a> keyword</a></h2>
<p>The <a href="../../lib/Pod/perlfunc.html#item_lock"><code>lock</code></a> keyword is the fundamental synchronization primitive
in threaded perl.  When threads are not enabled, it is currently a noop.</p>
<p>To minimize impact on source compatibility this keyword is &quot;weak&quot;, i.e., any
user-defined subroutine of the same name overrides it, unless a <code>use Thread</code>
has been seen.</p>
<p>
</p>
<h2><a name="new_qr___operator">New <a href="../../lib/Pod/perlfunc.html#item_qr_"><code>qr//</code></a> operator</a></h2>
<p>The <a href="../../lib/Pod/perlfunc.html#item_qr_"><code>qr//</code></a> operator, which is syntactically similar to the other quote-like
operators, is used to create precompiled regular expressions.  This compiled
form can now be explicitly passed around in variables, and interpolated in
other regular expressions.  See <a href="../../lib/Pod/perlop.html">the perlop manpage</a>.</p>
<p>
</p>
<h2><a name="our_is_now_a_reserved_word"><a href="../../lib/Pod/perlfunc.html#item_our"><code>our</code></a> is now a reserved word</a></h2>
<p>Calling a subroutine with the name <a href="../../lib/Pod/perlfunc.html#item_our"><code>our</code></a> will now provoke a warning when
using the <a href="../../lib/Pod/perlrun.html#item__2dw"><code>-w</code></a> switch.</p>
<p>
</p>
<h2><a name="tied_arrays_are_now_fully_supported">Tied arrays are now fully supported</a></h2>
<p>See <a href="../../lib/Tie/Array.html">the Tie::Array manpage</a>.</p>
<p>
</p>
<h2><a name="tied_handles_support_is_better">Tied handles support is better</a></h2>
<p>Several missing hooks have been added.  There is also a new base class for
TIEARRAY implementations.  See <a href="../../lib/Tie/Array.html">the Tie::Array manpage</a>.</p>
<p>
</p>
<h2><a name="4th_argument_to_substr">4th argument to substr</a></h2>
<p><a href="../../lib/Pod/perlvar.html#item_substr"><code>substr()</code></a> can now both return and replace in one operation.  The optional
4th argument is the replacement string.  See <a href="../../lib/Pod/perlfunc.html#substr">substr in the perlfunc manpage</a>.</p>
<p>
</p>
<h2><a name="negative_length_argument_to_splice">Negative LENGTH argument to splice</a></h2>
<p><a href="../../lib/Pod/perlfunc.html#item_splice"><code>splice()</code></a> with a negative LENGTH argument now work similar to what the
LENGTH did for substr().  Previously a negative LENGTH was treated as
0.  See <a href="../../lib/Pod/perlfunc.html#splice">splice in the perlfunc manpage</a>.</p>
<p>
</p>
<h2><a name="magic_lvalues_are_now_more_magical">Magic lvalues are now more magical</a></h2>
<p>When you say something like <a href="../../lib/Pod/perlvar.html#item_substr"><code>substr($x, 5) = &quot;hi&quot;</code></a>, the scalar returned
by <a href="../../lib/Pod/perlvar.html#item_substr"><code>substr()</code></a> is special, in that any modifications to it affect $x.
(This is called a 'magic lvalue' because an 'lvalue' is something on
the left side of an assignment.)  Normally, this is exactly what you
would expect to happen, but Perl uses the same magic if you use substr(),
pos(), or <a href="../../lib/Pod/perlfunc.html#item_vec"><code>vec()</code></a> in a context where they might be modified, like taking
a reference with <code>\</code> or as an argument to a sub that modifies <a href="../../lib/Pod/perlvar.html#item___"><code>@_</code></a>.
In previous versions, this 'magic' only went one way, but now changes
to the scalar the magic refers to ($x in the above example) affect the
magic lvalue too. For instance, this code now acts differently:</p>
<pre>
    <span class="variable">$x</span> <span class="operator">=</span> <span class="string">"hello"</span><span class="operator">;</span>
    <span class="keyword">sub</span><span class="variable"> printit </span><span class="operator">{</span>
        <span class="variable">$x</span> <span class="operator">=</span> <span class="string">"g'bye"</span><span class="operator">;</span>
        <span class="keyword">print</span> <span class="variable">$_</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">,</span> <span class="string">"\n"</span><span class="operator">;</span>
    <span class="operator">}</span>
    <span class="variable">printit</span><span class="operator">(</span><span class="keyword">substr</span><span class="operator">(</span><span class="variable">$x</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">5</span><span class="operator">));</span>
</pre>
<p>In previous versions, this would print &quot;hello&quot;, but it now prints &quot;g'bye&quot;.</p>
<p>
</p>
<h2><a name="___now_reads_in_records">&lt;&gt; now reads in records</a></h2>
<p>If <a href="../../lib/Pod/perlvar.html#item___"><code>$/</code></a> is a reference to an integer, or a scalar that holds an integer,
&lt;&gt; will read in records instead of lines. For more info, see
<a href="../../lib/Pod/perlvar.html#_e_sol_">$&sol; in the perlvar manpage</a>.</p>
<p>
</p>
<hr />
<h1><a name="supported_platforms">Supported Platforms</a></h1>
<p>Configure has many incremental improvements.  Site-wide policy for building
perl can now be made persistent, via Policy.sh.  Configure also records
the command-line arguments used in <em>config.sh</em>.</p>
<p>
</p>
<h2><a name="new_platforms">New Platforms</a></h2>
<p>BeOS is now supported.  See <em>README.beos</em>.</p>
<p>DOS is now supported under the DJGPP tools.  See <em>README.dos</em> (installed 
as <a href="../../lib/Pod/perldos.html">the perldos manpage</a> on some systems).</p>
<p>MiNT is now supported.  See <em>README.mint</em>.</p>
<p>MPE/iX is now supported.  See <em>README.mpeix</em>.</p>
<p>MVS (aka OS390, aka Open Edition) is now supported.  See <em>README.os390</em> 
(installed as <a href="../../lib/Pod/perlos390.html">the perlos390 manpage</a> on some systems).</p>
<p>Stratus VOS is now supported.  See <em>README.vos</em>.</p>
<p>
</p>
<h2><a name="changes_in_existing_support">Changes in existing support</a></h2>
<p>Win32 support has been vastly enhanced.  Support for Perl Object, a C++
encapsulation of Perl.  GCC and EGCS are now supported on Win32.
See <em>README.win32</em>, aka <a href="../../lib/Pod/perlwin32.html">the perlwin32 manpage</a>.</p>
<p>VMS configuration system has been rewritten.  See <em>README.vms</em> (installed 
as <em>README_vms</em> on some systems).</p>
<p>The hints files for most Unix platforms have seen incremental improvements.</p>
<p>
</p>
<hr />
<h1><a name="modules_and_pragmata">Modules and Pragmata</a></h1>
<p>
</p>
<h2><a name="new_modules">New Modules</a></h2>
<dl>
<dt><strong><a name="item_b">B</a></strong>

<dd>
<p>Perl compiler and tools.  See <a href="../../lib/B.html">the B manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_data_3a_3adumper">Data::Dumper</a></strong>

<dd>
<p>A module to pretty print Perl data.  See <a href="../../lib/Data/Dumper.html">the Data::Dumper manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_dumpvalue">Dumpvalue</a></strong>

<dd>
<p>A module to dump perl values to the screen. See <a href="../../lib/Dumpvalue.html">the Dumpvalue manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_errno">Errno</a></strong>

<dd>
<p>A module to look up errors more conveniently.  See <a href="../../lib/Errno.html">the Errno manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_file_3a_3aspec">File::Spec</a></strong>

<dd>
<p>A portable API for file operations.</p>
</dd>
</li>
<dt><strong><a name="item_extutils_3a_3ainstalled">ExtUtils::Installed</a></strong>

<dd>
<p>Query and manage installed modules.</p>
</dd>
</li>
<dt><strong><a name="item_extutils_3a_3apacklist">ExtUtils::Packlist</a></strong>

<dd>
<p>Manipulate .packlist files.</p>
</dd>
</li>
<dt><strong><a name="item_fatal">Fatal</a></strong>

<dd>
<p>Make functions/builtins succeed or die.</p>
</dd>
</li>
<dt><strong><a name="item_ipc_3a_3asysv">IPC::SysV</a></strong>

<dd>
<p>Constants and other support infrastructure for System V IPC operations
in perl.</p>
</dd>
</li>
<dt><strong><a name="item_test">Test</a></strong>

<dd>
<p>A framework for writing testsuites.</p>
</dd>
</li>
<dt><strong><a name="item_tie_3a_3aarray">Tie::Array</a></strong>

<dd>
<p>Base class for tied arrays.</p>
</dd>
</li>
<dt><strong><a name="item_tie_3a_3ahandle">Tie::Handle</a></strong>

<dd>
<p>Base class for tied handles.</p>

⌨️ 快捷键说明

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