perl5004delta.html

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

HTML
1,154
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>perl5004delta - what's new for perl5.004</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>perl5004delta - what's new for perl5.004</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#supported_environments">Supported Environments</a></li>
	<li><a href="#core_changes">Core Changes</a></li>
	<ul>

		<li><a href="#list_assignment_to__env_works">List assignment to %ENV works</a></li>
		<li><a href="#change_to_can_t_locate_foo_pm_in__inc_error">Change to &quot;Can't locate Foo.pm in @INC&quot; error</a></li>
		<li><a href="#compilation_option__binary_compatibility_with_5_003">Compilation option: Binary compatibility with 5.003</a></li>
		<li><a href="#_perl5opt_environment_variable">$PERL5OPT environment variable</a></li>
		<li><a href="#limitations_on_m__m__and_t_options">Limitations on <strong>-M</strong>, <strong>-m</strong>, and <strong>-T</strong> options</a></li>
		<li><a href="#more_precise_warnings">More precise warnings</a></li>
		<li><a href="#deprecated__inherited_autoload_for_nonmethods">Deprecated: Inherited <code>AUTOLOAD</code> for non-methods</a></li>
		<li><a href="#previously_deprecated__overload_is_no_longer_usable">Previously deprecated %OVERLOAD is no longer usable</a></li>
		<li><a href="#subroutine_arguments_created_only_when_they_re_modified">Subroutine arguments created only when they're modified</a></li>
		<li><a href="#group_vector_changeable_with___">Group vector changeable with <a href="../../lib/Pod/perlvar.html#item___"><code>$)</code></a></a></li>
		<li><a href="#fixed_parsing_of____digit______digit___etc_">Fixed parsing of $$&lt;digit&gt;, &amp;$&lt;digit&gt;, etc.</a></li>
		<li><a href="#fixed_localization_of___digit_______etc_">Fixed localization of $&lt;digit&gt;, $&amp;, etc.</a></li>
		<li><a href="#no_resetting_of____on_implicit_close">No resetting of $. on implicit close</a></li>
		<li><a href="#wantarray_may_return_undef"><a href="../../lib/Pod/perlfunc.html#item_wantarray"><code>wantarray</code></a> may return undef</a></li>
		<li><a href="#eval_expr_determines_value_of_expr_in_scalar_context"><a href="../../lib/Pod/perlfunc.html#item_eval"><code>eval EXPR</code></a> determines value of EXPR in scalar context</a></li>
		<li><a href="#changes_to_tainting_checks">Changes to tainting checks</a></li>
		<li><a href="#new_opcode_module_and_revised_safe_module">New Opcode module and revised Safe module</a></li>
		<li><a href="#embedding_improvements">Embedding improvements</a></li>
		<li><a href="#internal_change__filehandle_class_based_on_io____classes">Internal change: FileHandle class based on IO::* classes</a></li>
		<li><a href="#internal_change__perlio_abstraction_interface">Internal change: PerlIO abstraction interface</a></li>
		<li><a href="#new_and_changed_syntax">New and changed syntax</a></li>
		<li><a href="#new_and_changed_builtin_constants">New and changed builtin constants</a></li>
		<li><a href="#new_and_changed_builtin_variables">New and changed builtin variables</a></li>
		<li><a href="#new_and_changed_builtin_functions">New and changed builtin functions</a></li>
		<li><a href="#new_builtin_methods">New builtin methods</a></li>
		<li><a href="#tiehandle_now_supported">TIEHANDLE now supported</a></li>
		<li><a href="#malloc_enhancements">Malloc enhancements</a></li>
		<li><a href="#miscellaneous_efficiency_enhancements">Miscellaneous efficiency enhancements</a></li>
	</ul>

	<li><a href="#support_for_more_operating_systems">Support for More Operating Systems</a></li>
	<ul>

		<li><a href="#win32">Win32</a></li>
		<li><a href="#plan_9">Plan 9</a></li>
		<li><a href="#qnx">QNX</a></li>
		<li><a href="#amigaos">AmigaOS</a></li>
	</ul>

	<li><a href="#pragmata">Pragmata</a></li>
	<li><a href="#modules">Modules</a></li>
	<ul>

		<li><a href="#required_updates">Required Updates</a></li>
		<li><a href="#installation_directories">Installation directories</a></li>
		<li><a href="#module_information_summary">Module information summary</a></li>
		<li><a href="#fcntl">Fcntl</a></li>
		<li><a href="#io">IO</a></li>
		<li><a href="#math__complex">Math::Complex</a></li>
		<li><a href="#math__trig">Math::Trig</a></li>
		<li><a href="#db_file">DB_File</a></li>
		<li><a href="#net__ping">Net::Ping</a></li>
		<li><a href="#objectoriented_overrides_for_builtin_operators">Object-oriented overrides for builtin operators</a></li>
	</ul>

	<li><a href="#utility_changes">Utility Changes</a></li>
	<ul>

		<li><a href="#pod2html">pod2html</a></li>
		<li><a href="#xsubpp">xsubpp</a></li>
	</ul>

	<li><a href="#c_language_api_changes">C Language API Changes</a></li>
	<li><a href="#documentation_changes">Documentation Changes</a></li>
	<li><a href="#new_diagnostics">New Diagnostics</a></li>
	<li><a href="#bugs">BUGS</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#history">HISTORY</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>perl5004delta - what's new for perl5.004</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This document describes differences between the 5.003 release (as
documented in <em>Programming Perl</em>, second edition--the Camel Book) and
this one.</p>
<p>
</p>
<hr />
<h1><a name="supported_environments">Supported Environments</a></h1>
<p>Perl5.004 builds out of the box on Unix, Plan 9, LynxOS, VMS, OS/2,
QNX, AmigaOS, and Windows NT.  Perl runs on Windows 95 as well, but it
cannot be built there, for lack of a reasonable command interpreter.</p>
<p>
</p>
<hr />
<h1><a name="core_changes">Core Changes</a></h1>
<p>Most importantly, many bugs were fixed, including several security
problems.  See the <em>Changes</em> file in the distribution for details.</p>
<p>
</p>
<h2><a name="list_assignment_to__env_works">List assignment to %ENV works</a></h2>
<p><a href="../../lib/Pod/perlvar.html#item__env"><code>%ENV = ()</code></a> and <a href="../../lib/Pod/perlvar.html#item__env"><code>%ENV = @list</code></a> now work as expected (except on VMS
where it generates a fatal error).</p>
<p>
</p>
<h2><a name="change_to_can_t_locate_foo_pm_in__inc_error">Change to &quot;Can't locate Foo.pm in @INC&quot; error</a></h2>
<p>The error &quot;Can't locate Foo.pm in @INC&quot; now lists the contents of @INC
for easier debugging.</p>
<p>
</p>
<h2><a name="compilation_option__binary_compatibility_with_5_003">Compilation option: Binary compatibility with 5.003</a></h2>
<p>There is a new Configure question that asks if you want to maintain
binary compatibility with Perl 5.003.  If you choose binary
compatibility, you do not have to recompile your extensions, but you
might have symbol conflicts if you embed Perl in another application,
just as in the 5.003 release.  By default, binary compatibility
is preserved at the expense of symbol table pollution.</p>
<p>
</p>
<h2><a name="_perl5opt_environment_variable">$PERL5OPT environment variable</a></h2>
<p>You may now put Perl options in the $PERL5OPT environment variable.
Unless Perl is running with taint checks, it will interpret this
variable as if its contents had appeared on a &quot;#!perl&quot; line at the
beginning of your script, except that hyphens are optional.  PERL5OPT
may only be used to set the following switches: <strong>-[DIMUdmw]</strong>.</p>
<p>
</p>
<h2><a name="limitations_on_m__m__and_t_options">Limitations on <strong>-M</strong>, <strong>-m</strong>, and <strong>-T</strong> options</a></h2>
<p>The <code>-M</code> and <code>-m</code> options are no longer allowed on the <code>#!</code> line of
a script.  If a script needs a module, it should invoke it with the
<a href="#item_use"><code>use</code></a> pragma.</p>
<p>The <strong>-T</strong> option is also forbidden on the <code>#!</code> line of a script,
unless it was present on the Perl command line.  Due to the way <code>#!</code>
works, this usually means that <strong>-T</strong> must be in the first argument.
Thus:</p>
<pre>
    <span class="comment">#!/usr/bin/perl -T -w</span>
</pre>
<p>will probably work for an executable script invoked as <code>scriptname</code>,
while:</p>
<pre>
    <span class="comment">#!/usr/bin/perl -w -T</span>
</pre>
<p>will probably fail under the same conditions.  (Non-Unix systems will
probably not follow this rule.)  But <code>perl scriptname</code> is guaranteed
to fail, since then there is no chance of <strong>-T</strong> being found on the
command line before it is found on the <code>#!</code> line.</p>
<p>
</p>
<h2><a name="more_precise_warnings">More precise warnings</a></h2>
<p>If you removed the <strong>-w</strong> option from your Perl 5.003 scripts because it
made Perl too verbose, we recommend that you try putting it back when
you upgrade to Perl 5.004.  Each new perl version tends to remove some
undesirable warnings, while adding new warnings that may catch bugs in
your scripts.</p>
<p>
</p>
<h2><a name="deprecated__inherited_autoload_for_nonmethods">Deprecated: Inherited <code>AUTOLOAD</code> for non-methods</a></h2>
<p>Before Perl 5.004, <code>AUTOLOAD</code> functions were looked up as methods
(using the <code>@ISA</code> hierarchy), even when the function to be autoloaded
was called as a plain function (e.g. <code>Foo::bar()</code>), not a method
(e.g. <code>Foo-&gt;bar()</code> or <code>$obj-&gt;bar()</code>).</p>
<p>Perl 5.005 will use method lookup only for methods' <code>AUTOLOAD</code>s.
However, there is a significant base of existing code that may be using
the old behavior.  So, as an interim step, Perl 5.004 issues an optional
warning when a non-method uses an inherited <code>AUTOLOAD</code>.</p>
<p>The simple rule is:  Inheritance will not work when autoloading
non-methods.  The simple fix for old code is:  In any module that used to
depend on inheriting <code>AUTOLOAD</code> for non-methods from a base class named
<code>BaseClass</code>, execute <code>*AUTOLOAD = \&amp;BaseClass::AUTOLOAD</code> during startup.</p>
<p>
</p>
<h2><a name="previously_deprecated__overload_is_no_longer_usable">Previously deprecated %OVERLOAD is no longer usable</a></h2>
<p>Using %OVERLOAD to define overloading was deprecated in 5.003.
Overloading is now defined using the overload pragma. %OVERLOAD is
still used internally but should not be used by Perl scripts. See
<a href="../../lib/overload.html">the overload manpage</a> for more details.</p>
<p>
</p>
<h2><a name="subroutine_arguments_created_only_when_they_re_modified">Subroutine arguments created only when they're modified</a></h2>
<p>In Perl 5.004, nonexistent array and hash elements used as subroutine
parameters are brought into existence only if they are actually
assigned to (via <a href="../../lib/Pod/perlvar.html#item___"><code>@_</code></a>).</p>
<p>Earlier versions of Perl vary in their handling of such arguments.
Perl versions 5.002 and 5.003 always brought them into existence.
Perl versions 5.000 and 5.001 brought them into existence only if
they were not the first argument (which was almost certainly a bug).
Earlier versions of Perl never brought them into existence.</p>
<p>For example, given this code:</p>
<pre>
     <span class="keyword">undef</span> <span class="variable">@a</span><span class="operator">;</span> <span class="keyword">undef</span> <span class="variable">%a</span><span class="operator">;</span>
     <span class="keyword">sub</span><span class="variable"> show </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="keyword">sub</span><span class="variable"> change </span><span class="operator">{</span> <span class="variable">$_</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">++</span> <span class="operator">};</span>
     <span class="variable">show</span><span class="operator">(</span><span class="variable">$a</span><span class="operator">[</span><span class="number">2</span><span class="operator">]</span><span class="operator">);</span>
     <span class="variable">change</span><span class="operator">(</span><span class="variable">$a</span><span class="operator">{</span><span class="string">b</span><span class="operator">}</span><span class="operator">);</span>
</pre>
<p>After this code executes in Perl 5.004, $a{b} exists but $a[2] does
not.  In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed
(but $a[2]'s value would have been undefined).</p>
<p>
</p>
<h2><a name="group_vector_changeable_with___">Group vector changeable with <a href="../../lib/Pod/perlvar.html#item___"><code>$)</code></a></a></h2>

⌨️ 快捷键说明

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