perlman
gods
<HR>
<P>
<H1><A NAME="NAME">NAME</A></H1>
<P>
perldelta - what's new for perl5.004
<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>
<HR>
<H1><A NAME="Supported_Environments">Supported Environments</A></H1>
<P>
Perl5.004 builds out of the box on Unix, Plan 9, LynxOS,
<FONT SIZE=-1>VMS,</FONT>
<FONT SIZE=-1>OS/2,</FONT>
<FONT SIZE=-1>QNX,</FONT> AmigaOS, and Windows
<FONT SIZE=-1>NT.</FONT> Perl runs on Windows 95 as well, but it cannot be built there, for lack of a reasonable command interpreter.
<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>
<HR>
<H2><A NAME="List_assignment_to_ENV_works">List assignment to %ENV works</A></H2>
<P>
<CODE>%ENV = ()</CODE> and <CODE>%ENV = @list</CODE> now work as expected (except on
<FONT SIZE=-1>VMS</FONT> where it generates a fatal error).
<P>
<HR>
<H2><A NAME="_Can_t_locate_Foo_pm_in_INC_er">"Can't locate Foo.pm in @INC" error now lists @INC</A></H2>
<P>
<HR>
<H2><A NAME="Compilation_option_Binary_compa">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>
<HR>
<H2><A NAME="_PERL5OPT_environment_variable">$PERL5OPT environment variable</A></H2>
<P>
You may now put Perl options in the [perlman:perlrun] environment variable. Unless Perl is running with taint checks, it will interpret this variable as if its contents had appeared on a ``#!perl'' line at the beginning of your script, except that hyphens are optional.
<FONT SIZE=-1>PERL5OPT</FONT> may only be used to set the following switches:
<STRONG>-[DIMUdmw]</STRONG>.
<P>
<HR>
<H2><A NAME="Limitations_on_B_M_B_m_and">Limitations on <STRONG>-M</STRONG>, <STRONG>-m</STRONG>, and <STRONG>-T</STRONG> options</A></H2>
<P>
The <CODE>-M</CODE> and [perlman:perlop] 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
[perlfunc:use|use] pragma.
<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> #!/usr/bin/perl -T -w
</PRE>
<P>
will probably work for an executable script invoked as <CODE>scriptname</CODE>, while:
<P>
<PRE> #!/usr/bin/perl -w -T
</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>
<HR>
<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>
<HR>
<H2><A NAME="Deprecated_Inherited_C_AUTOLOAD">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->bar()</CODE> or <CODE>$obj->bar()</CODE>).
<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>
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 = \&BaseClass::AUTOLOAD</CODE> during startup.
<P>
<HR>
<H2><A NAME="Previously_deprecated_OVERLOAD_">Previously deprecated %OVERLOAD is no longer usable</A></H2>
<P>
Using <CODE>%OVERLOAD</CODE> to define overloading was deprecated in 5.003.
Overloading is now defined using the overload pragma.
<CODE>%OVERLOAD</CODE> is still used internally but should not be used by
Perl scripts. See
<U>the overload manpage</U><!--../lib/overload.html--> for more details.
<P>
<HR>
<H2><A NAME="Subroutine_arguments_created_onl">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 <CODE>@_</CODE>).
<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>
For example, given this code:
<P>
<PRE> undef @a; undef %a;
sub show { print $_[0] };
sub change { $_[0]++ };
show($a[2]);
change($a{b});
</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>
<HR>
<H2><A NAME="Group_vector_changeable_with_C_">Group vector changeable with <CODE>$)</CODE></A></H2>
<P>
The <CODE>$)</CODE> special variable has always (well, in Perl 5, at least) reflected not only
the current effective group, but also the group list as returned by the <CODE>getgroups()</CODE>
<FONT SIZE=-1>C</FONT> function (if there is one). However, until this
release, there has not been a way to call the
<CODE>setgroups()</CODE>
<FONT SIZE=-1>C</FONT> function from Perl.
<P>
In Perl 5.004, assigning to <CODE>$)</CODE> is exactly symmetrical with examining it: The first number in its string
value is used as the effective gid; if there are any numbers after the
first one, they are passed to the
<CODE>setgroups()</CODE>
<FONT SIZE=-1>C</FONT> function (if there is one).
<P>
<HR>
<H2><A NAME="Fixed_parsing_of_digit_d">Fixed parsing of $$<digit>, &$<digit>, etc.</A></H2>
<P>
Perl versions before 5.004 misinterpreted any type marker followed by ``$''
and a digit. For example, ``$$0'' was incorrectly taken to mean ``${$}0''
instead of ``${$0}''. This bug is (mostly) fixed in Perl 5.004.
<P>
However, the developers of Perl 5.004 could not fix this bug completely,
because at least two widely-used modules depend on the old meaning of
``$$0'' in a string. So Perl 5.004 still interprets ``$$<digit>'' in
the old (broken) way inside strings; but it generates this message as a
warning. And in Perl 5.005, this special treatment will cease.
<P>
<HR>
<H2><A NAME="Fixed_localization_of_digit_">Fixed localization of $<digit>, $&, etc.</A></H2>
<P>
Perl versions before 5.004 did not always properly localize the
regex-related special variables. Perl 5.004 does localize them, as the
documentation has always said it should. This may result in $1, $2, etc. no
longer being set where existing programs use them.
<P>
<HR>
<H2><A NAME="No_resetting_of_on_implicit_c">No resetting of $. on implicit close</A></H2>
<P>
The documentation for Perl 5.0 has always stated that <CODE>$.</CODE> is <EM>not</EM>
reset when an already-open file handle is reopened with no intervening call
to [perlfunc:close|close]. Due to a bug, perl versions 5.000 through 5.003
<EM>did</EM> reset <CODE>$.</CODE> under that circumstance; Perl 5.004 does not.
<P>
<HR>
<H2><A NAME="C_wantarray_may_return_undef">[perlfunc:wantarray|wantarray] may return undef</A></H2>
<P>
The [perlfunc:wantarray|wantarray] operator returns true if a subroutine is expected to return a list, and
false otherwise. In Perl 5.004, [perlfunc:wantarray|wantarray] can also return the undefined value if a subroutine's return value will not
be used at all, which allows subroutines to avoid a time-consuming
calculation of a return value if it isn't going to be used.
<P>
<HR>
<H2><A NAME="C_eval_EXPR_determines_value_of"><CODE>eval EXPR</CODE> determines value of EXPR in scalar context</A></H2>
<P>
Perl (version 5) used to determine the value of
<FONT SIZE=-1>EXPR</FONT> inconsistently, sometimes incorrectly using the surrounding context for the determination. Now, the value of
<FONT SIZE=-1>EXPR</FONT> (before being parsed by eval) is always determined in a scalar context. Once parsed, it is executed as before, by providing the context that the scope surrounding the eval provided. This change makes the behavior Perl4 compatible, besides fixing bugs resulting from the inconsistent behavior. This program:
<P>
<PRE> @a = qw(time now is time);
print eval @a;
print '|', scalar eval @a;
</PRE>
<P>
used to print something like ``timenowis881399109|4'', but now (and in
perl4) prints ``4|4''.
<P>
<HR>
<H2><A NAME="Changes_to_tainting_checks">Changes to tainting checks</A></H2>
<P>
<FONT SIZE=-1>A</FONT> bug in previous versions may have failed to detect
some insecure conditions when taint checks are turned on. (Taint checks are
used in setuid or setgid scripts, or when explicitly turned on with the
<CODE>-T</CODE> invocation option.) Although it's unlikely, this may cause a
previously-working script to now fail -- which should be construed as a
blessing, since that indicates a potentially-serious security hole was just
plugged.
<P>
The new restrictions when tainting include:
<DL>
<DT><STRONG><A NAME="item_No">No glob() or <*></A></STRONG><P>
<DD>
These operators may spawn the
<FONT SIZE=-1>C</FONT> shell (csh), which cannot be made safe. This
restriction will be lifted in a future version of Perl when globbing is
implemented without the use of an external program.
<P><DT><STRONG>No spawning if tainted $CDPATH, $ENV, $BASH_ENV</STRONG><P>
<DD>
These environment variables may alter the behavior of spawned programs (especially shells) in ways that subvert security. So now they are treated as dangerous, in the manner of <CODE>$IFS</CODE> and
<FONT SIZE=-1>$PATH.</FONT>
<P><DT><STRONG>No spawning if tainted $TERM doesn't look like a terminal name</STRONG><P>
<DD>
Some termcap libraries do unsafe things with
<FONT SIZE=-1>$TERM.</FONT> However, it would be unnecessarily harsh to treat all <CODE>$TERM</CODE> values as unsafe, since only shell metacharacters can cause trouble in
<FONT SIZE=-1>$TERM.</FONT> So a tainted <CODE>$TERM</CODE> is considered to be safe if it contains only alphanumerics, underscores, dashes, and colons, and unsafe if it contains other characters (including whitespace).
</DL>
<P>
<HR>
<H2><A NAME="New_Opcode_module_and_revised_Sa">New Opcode module and revised Safe module</A></H2>
<P>
<FONT SIZE=-1>A</FONT> new Opcode module supports the creation, manipulation and application of opcode masks. The revised Safe module has a new
<FONT SIZE=-1>API</FONT> and is implemented using the new Opcode module. Please read the new Opcode and Safe documentation.
<P>
<HR>
<H2><A NAME="Embedding_improvements">Embedding improvements</A></H2>
<P>
In older versions of Perl it was not possible to create more than one Perl interpreter instance inside a single process without leaking like a sieve and/or crashing. The bugs that caused this behavior have all been fixed. However, you still must take care when embedding Perl in a
<FONT SIZE=-1>C</FONT> program. See the updated perlembed manpage for tips on how to manage your interpreters.
<P>
<HR>
<H2><A NAME="Internal_change_FileHandle_clas">Internal change: FileHandle class based on IO::* classes</A></H2>
<P>
File handles are now stored internally as type IO::Handle. The FileHandle module is still supported for backwards compatibility, but it is now merely a front end to the
<FONT SIZE=-1>IO::*</FONT> modules -- specifically, IO::Handle, IO::Seekable, and IO::File. We suggest, but do not require, that you use the
<FONT SIZE=-1>IO::*</FONT> modules in new code.
<P>
In harmony with this change, <CODE>*GLOB{FILEHANDLE}</CODE> is now just a backward-compatible synonym for <CODE>*GLOB{IO}</CODE>.
<P>
<HR>
<H2><A NAME="Internal_change_PerlIO_abstract">Internal change: PerlIO abstraction interface</A></H2>
<P>
It is now possible to build Perl with AT&T's sfio
<FONT SIZE=-1>IO</FONT> package instead of stdio. See [perlman:perlapio|the perlapio manpage] for more details, and the <EM>INSTALL</EM> file for how to use it.
<P>
<HR>
<H2><A NAME="New_and_changed_syntax">New and changed syntax</A></H2>
<DL>
<DT><STRONG><A NAME="item__coderef_PARAMS_">$coderef->(PARAMS)</A></STRONG><P>
<DD>
<FONT SIZE=-1>A</FONT> subroutine reference may now be suffixed with an
arrow and a (possibly empty) parameter list. This syntax denotes a call of
the referenced subroutine, with the given parameters (if any).
<P>
This new syntax follows the pattern of <CODE>$hashref->{FOO}</CODE> and
<CODE>$aryref->[$foo]</CODE>: You may now write <CODE>&$subref($foo)</CODE> as
<CODE>$subref->($foo)</CODE>. All of these arrow terms may be chained; thus, <CODE>&{$table->{FOO}}($bar)</CODE> may now be written
<CODE>$table->{FOO}->($bar)</CODE>.
</DL>
<P>
<HR>
<H2><A NAME="New_and_changed_builtin_constant">New and changed builtin constants</A></H2>
<DL>
<DT><STRONG><A NAME="item__PACKAGE_">__PACKAGE__</A></STRONG><P>
<DD>
The current package name at compile time, or the undefined value if there
is no current package (due to a [perlfunc:package] directive). Like
<CODE>__FILE__</CODE> and <CODE>__LINE__</CODE>, <CODE>__PACKAGE__</CODE> does <EM>not</EM> interpolate into strings.
</DL>
<P>
<HR>
<H2><A NAME="New_and_changed_builtin_variable">New and changed builtin variables</A></H2>
<DL>
<DT><STRONG><A NAME="item__E">$^E</A></STRONG><P>
<DD>
Extended error message on some platforms. (Also known as
<CODE>$EXTENDED_OS_ERROR</CODE> if you <CODE>use English</CODE>).
<P><DT><STRONG><A NAME="item__H">$^H</A></STRONG><P>
<DD>
The current set of syntax checks enabled by <CODE>use strict</CODE>. See the documentation of <CODE>strict</CODE> for more details. Not actually new, but newly documented. Because it is
intended for internal use by Perl core components, there is no <CODE>use English</CODE> long name for this variable.
<P><DT><STRONG><A NAME="item__M">$^M</A></STRONG><P>
<DD>
By default, running out of memory it is not trappable. However, if compiled
for this, Perl may use the contents of <CODE>$^M</CODE> as an emergency pool after
<CODE>die()ing</CODE> with this message. Suppose that your Perl were compiled with
<FONT SIZE=-1>-DPERL_EMERGENCY_SBRK</FONT> and used Perl's malloc. Then
<P>
<PRE> $^M = 'a' x (1<<16);
</PRE>
<P>
would allocate a
<FONT SIZE=-1>64K</FONT> buffer for use when in emergency. See the <EM>INSTALL</EM> file for information on how to enable this option. As a disincentive to
casual use of this advanced feature, there is no <CODE>use English</CODE> long name for this variable.
</DL>
<P>
<HR>
<H2><A NAME="New_and_changed_builtin_function">New and changed builtin functions</A></H2>
<DL>
<DT><STRONG><A NAME="item_delete">delete on slices</A></STRONG><P>
<DD>
This now works. (e.g. <CODE>delete @ENV{'PATH', 'MANPATH'}</CODE>)
<P><DT><STRONG><A NAME="item_flock">flock</A></STRONG><P>
<DD>
is now supported on more platforms, prefers fcntl to lockf when emulating,
and always flushes before (un)locking.
<P><DT><STRONG><A NAME="item_printf">printf and sprintf</A></STRONG><P>
<DD>
Perl now implements these functions itself; it doesn't use the
<FONT SIZE=-1>C</FONT> library function
<CODE>sprintf()</CODE> any more, except for floating-point numbers, and even then only known flags are allowed. As a result, it is now possible to know which conversions and flags will work, and what they will do.
<P>
The new conversions in Perl's
<CODE>sprintf()</CODE> are:
<P>
<PRE> %i a synonym for %d
%p a pointer (the address of the Perl value, in hexadecimal)
%n special: *stores* the number of characters output so far
into the next variable in the parameter list
</PRE>
<P>
The new flags that go between the <CODE>%</CODE> and the conversion are:
<P>
<PRE> # prefix octal with "0", hex with "0x"
h interpret integer as C type "short" or "unsigned short"
V interpret integer as Perl's standard integer type
</PRE>
<P>
Also, where a number would appear in the flags, an asterisk (``*'') may be
used instead, in which case Perl uses the next item in the parameter list
as the given number (that is, as the field width or precision). If a field
width obtained through ``*'' is negative, it has the same effect as the '-'
flag: left-justification.
<P>
See [perlfunc:sprintf|sprintf] for a complete list of conversion and flags.
<P><DT><STRONG><A NAME="item_keys">keys as an lvalue</A></STRONG><P>
<DD>
As an lvalue, [perlfunc:keys|keys] allows you to increase the number of hash buckets allocated for the given
hash. This can gain you a measure of efficiency if you know the hash is
going to get big. (This is similar to pre-extending an array by assigning a
larger number to $#array.) If you say
<P>
<PRE> keys %hash = 200;
</PRE>
<P>
then <CODE>%hash</CODE> will have at least 200 buckets allocated for it. These buckets will be
retained even if you do <CODE>%hash = ()</CODE>; use <CODE>undef
%hash</CODE> if you want to free the storage while <CODE>%hash</CODE> is still in scope. You can't shrink the number of buckets allocated for the
hash using
[perlfunc:keys|keys] in this way (but you needn't worry about doing this by accident, as trying
has no effect).
<P><DT><STRONG><A NAME="item_my">my() in Control Structures</A></STRONG><P>
<DD>
You can now use
<CODE>my()</CODE> (with or without the
parentheses) in the control expressions of control structures such as:
<P>
<PRE> while (defined(my $line = <>)) {
$line = lc $line;
} continue {
print $line;
}
</PRE>
<P>
<PRE> if ((my $answer = <STDIN>) =~ /^y(es)?$/i) {
user_agrees();
} elsif ($answer =~ /^n(o)?$/i) {
user_disagrees();
} else {
chomp $answer;
die "`$answer' is neither `yes' nor `no'";
}
</PRE>
<P>
Also, you can declare a foreach loop control variable as lexical by
preceding it with the word ``my''. For example, in:
<P>
<PRE> foreach my $i (1, 2, 3) {
some_function();
}
</PRE>
<P>
<CODE>$i</CODE> is a lexical variable, and the scope of <CODE>$i</CODE>
extends to the end of the loop, but not beyond it.
<P>
Note that you still cannot use
<CODE>my()</CODE> on global punctuation
variables such as <CODE>$_</CODE> and the like.
<P><DT><STRONG><A NAME="item_pack">pack() and unpack()</A></STRONG><P>
<DD>
<FONT SIZE=-1>A</FONT> new format 'w' represents a
<FONT SIZE=-1>BER</FONT> compressed integer (as defined in
<FONT SIZE=-1>ASN.1).</FONT> Its format is a sequence of one or more bytes, each of which provides seven bits of the total value, with the most significant first. Bit eight of each byte is set, except for the last byte, in which bit eight is clear.
<P>
If 'p' or
<FONT SIZE=-1>'P'</FONT> are given undef as values, they now generate a
<FONT SIZE=-1>NULL</FONT> pointer.
<P>
Both
<CODE>pack()</CODE> and
<CODE>unpack()</CODE> now fail when their templates contain invalid types. (Invalid types used to be ignored.)
<P><DT><STRONG><A NAME="item_sysseek">sysseek()</A></STRONG><P>
<DD>
The new
<CODE>sysseek()</CODE> operator is a variant of
<CODE>seek()</CODE> that sets and gets the file's system read/write position, using the
<CODE>lseek(2)</CODE> system call. It is the only reliable way to seek before using
<CODE>sysread()</CODE> or
<CODE>syswrite().</CODE> Its return value is the new position, or the undefined value on failure.
<P><DT><STRONG><A NAME="item_use">use VERSION</A></STRONG><P>
<DD>
If the first argument to [perlfunc:use|use] is a number, it is treated as a version number instead of a module name. If the version of the Perl interpreter is less than
<FONT SIZE=-1>VERSION,</FONT> then an error message is printed and Perl exits immediately. Because
[perlfunc:use|use] occurs at compile time, this check happens immediately during the
compilation process, unlike <CODE>require VERSION</CODE>, which waits until runtime for the check. This is often useful if you need
to check the current Perl version before [perlfunc:use|use]ing library modules which have changed in incompatible ways from older
versions of Perl. (We try not to do this more than we have to.)
<P><DT><STRONG>use Module VERSION LIST</STRONG><P>
<DD>
If the
<FONT SIZE=-1>VERSION</FONT> argument is present between Module and
<FONT SIZE=-1>LIST,</FONT> then the
[perlfunc:use|use] will call the
<FONT SIZE=-1>VERSION</FONT> method in class Module with the given version as an argument. The default
<FONT SIZE=-1>VERSION</FONT> method, inherited from the
<FONT SIZE=-1>UNIVERSAL</FONT> class, croaks if the given version is larger than the value of the variable $Module::VERSION. (Note that there is not a comma after
<FONT SIZE=-1>VERSION!)</FONT>
<P>
This version-checking mechanism is similar to the one currently used in the
Exporter module, but it is faster and can be used with modules that don't
use the Exporter. It is the recommended method for new code.
<P><DT><STRONG><A NAME="item_prototype">prototype(FUNCTION)</A></STRONG><P>
<DD>
Returns the prototype of a function as a string (or [perlfunc:undef|undef] if the function has no prototype).
<FONT SIZE=-1>FUNCTION</FONT> is a reference to or the name of the function
whose prototype you want to retrieve. (Not actually new; just never
documented before.)
<P><DT><STRONG><A NAME="item_srand">srand</A></STRONG><P>
<DD>
The default seed for [perlfunc:srand|srand], which used to be [perlfunc:time|time], has been changed. Now it's a heady mix of difficult-to-predict
system-dependent values, which should be sufficient for most everyday
purposes.
<P>
Previous to version 5.004, calling [perlfunc:rand|rand] without first calling [perlfunc:srand|srand]
would yield the same sequence of random numbers on most or all machines.
Now, when perl sees that you're calling [perlfunc:rand|rand] and haven't yet called
[perlfunc:srand|srand], it calls [perlfunc:srand|srand] with the default seed. You should still call
[perlfunc:srand|srand] manually if your code might ever be run on a pre-5.004 system, of course,
or if you want a seed other than the default.
<P><DT><STRONG><A NAME="item__">$_ as Default</A></STRONG><P>
<DD>
Functions documented in the Camel to default to <CODE>$_</CODE> now in fact
do, and all those that do are so documented in [perlman:perlfunc|the perlfunc manpage].
<P><DT><STRONG><A NAME="item_m">m//gc does not reset search position on failure</A></STRONG><P>
<DD>
The <CODE>m//g</CODE> match iteration construct has always reset its target string's search
position (which is visible through the [perlfunc:pos|pos] operator) when a match fails; as a result, the next <CODE>m//g</CODE> match after a failure starts again at the beginning of the string. With
Perl 5.004, this reset may be disabled by adding the ``c'' (for
``continue'') modifier, i.e. <CODE>m//gc</CODE>. This feature, in conjunction with the <CODE>\G</CODE> zero-width assertion, makes it possible to chain matches together. See [perlman:perlop|the perlop manpage]
and [perlman:perlre|the perlre manpage].
<P><DT><STRONG><A NAME="item_m">m//x ignores whitespace before ?*+{}</A></STRONG><P>
<DD>
The <CODE>m//x</CODE> construct has always been intended to ignore all unescaped whitespace.
However, before Perl 5.004, whitespace had the effect of escaping repeat
modifiers like ``*'' or ``?''; for example, <CODE>/a *b/x</CODE> was (mis)interpreted as <CODE>/a\*b/x</CODE>. This bug has been fixed in 5.004.
<P><DT><STRONG><A NAME="item_nested">nested sub{} closures work now</A></STRONG><P>
<DD>
Prior to the 5.004 release, nested anonymous functions didn't work right.
They do now.
<P><DT><STRONG><A NAME="item_formats">formats work right on changing lexicals</A></STRONG><P>
<DD>
Just like anonymous functions that contain lexical variables that change
(like a lexical index variable for a <CODE>foreach</CODE> loop), formats now work properly. For example, this silently failed before
(printed only zeros), but is fine now:
<P>
<PRE> my $i;
foreach $i ( 1 .. 10 ) {
write;
}
format =
my i is @#
$i
.
</PRE>
<P>
However, it still fails (without a warning) if the foreach is within a
subroutine:
<P>
<PRE> my $i;
sub foo {
foreach $i ( 1 .. 10 ) {
write;
}
}
foo;
format =
my i is @#
$i
.
</PRE>
</DL>
<P>
<HR>
<H2><A NAME="New_builtin_methods">New builtin methods</A></H2>
<P>
The <CODE>UNIVERSAL</CODE> package automatically contains the following methods that are inherited by
all other classes:
<DL>
<DT><STRONG><A NAME="item_isa">isa(CLASS)</A></STRONG><P>
<DD>
<CODE>isa</CODE> returns <EM>true</EM> if its object is blessed into a subclass of [perlman:perlguts]
<P>
<CODE>isa</CODE> is also exportable and can be called as a sub with two arguments. This
allows the ability to check what a reference points to. Example:
<P>
<PRE> use UNIVERSAL qw(isa);
</PRE>
<P>
<PRE> if(isa($ref, 'ARRAY')) {
...
}
</PRE>
<DT><STRONG><A NAME="item_can">can(METHOD)</A></STRONG><P>
<DD>
<CODE>can</CODE> checks to see if its object has a method called <CODE>METHOD</CODE>, if it does then a reference to the sub is returned; if it does not then
<EM>undef</EM> is returned.
<P><DT><STRONG><A NAME="item_VERSION">VERSION( [NEED] )</A></STRONG><P>
<DD>
<CODE>VERSION</CODE> returns the version number of the class (package). If the
<FONT SIZE=-1>NEED</FONT> argument is given then it will check that the current version (as defined by the <CODE>$VERSION</CODE> variable in the given package) not less than
<FONT SIZE=-1>NEED;</FONT> it will die if this is not the case. This method is normally called as a class method. This method is called automatically by the
<CODE>VERSION</CODE> form of [perlfunc:use|use].
<P>
<PRE> use A 1.2 qw(some imported subs);
# implies:
A->VERSION(1.2);
</PRE>
</DL>
<P>
<STRONG>NOTE:</STRONG> <CODE>can</CODE> directly uses Perl's internal code for method lookup, and
<CODE>isa</CODE> uses a very similar method and caching strategy. This may cause strange
effects if the Perl code dynamically changes <CODE>@ISA</CODE> in any
package.
<P>
You may add other methods to the
<FONT SIZE=-1>UNIVERSAL</FONT> class via Perl or
<FONT SIZE=-1>XS</FONT> code. You do not need to
<CODE>use UNIVERSAL</CODE> in order to make these methods available to your program. This is necessary
only if you wish to have <CODE>isa</CODE> available as a plain subroutine in the current package.
<P>
<HR>
<H2><A NAME="TIEHANDLE_now_supported">TIEHANDLE now supported</A></H2>
<P>
See [perlman:perltie|the perltie manpage] for other kinds of
<CODE>tie()s.</CODE>
<DL>
<DT><STRONG><A NAME="item_TIEHANDLE">TIEHANDLE classname, LIST</A></STRONG><P>
<DD>
This is the constructor for the class. That means it is expected to return
an object of some sort. The reference can be used to hold some internal
information.
<P>
<PRE> sub TIEHANDLE {
print "<shout>\n";
my $i;
return bless \$i, shift;
}
</PRE>
<DT><STRONG><A NAME="item_PRINT">PRINT this, LIST</A></STRONG><P>
<DD>
This method will be triggered every time the tied handle is printed to.
Beyond its self reference it also expects the list that was passed to the
print function.
<P>
<PRE> sub PRINT {
$r = shift;
$$r++;
return print join( $, => map {uc} @_), $\;
}
</PRE>
<DT><STRONG><A NAME="item_PRINTF">PRINTF this, LIST</A></STRONG><P>
<DD>
This method will be triggered every time the tied handle is printed to with
the [perlfunc:printf|printf()] function. Beyond its self reference it also expects the format and list
that was passed to the printf function.
<P>
<PRE> sub PRINTF {
shift;
my $fmt = shift;
print sprintf($fmt, @_)."\n";
}
</PRE>
<DT><STRONG><A NAME="item_READ">READ this LIST</A></STRONG><P>
<DD>
This method will be called when the handle is read from via the [perlfunc:read|read]
or [perlfunc:sysread|sysread] functions.
<P>
<PRE> sub READ {
$r = shift;
my($buf,$len,$offset) = @_;
print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
}
</PRE>
<DT><STRONG><A NAME="item_READLINE">READLINE this</A></STRONG><P>
<DD>
This method will be called when the handle is read from. The method should
return undef when there is no more data.
<P>
<PRE> sub READLINE {
$r = shift;
return "PRINT called $$r times\n"
}
</PRE>
<DT><STRONG><A NAME="item_GETC">GETC this</A></STRONG><P>
<DD>
This method will be called when the [perlfunc:getc|getc] function is called.
<P>
<PRE> sub GETC { print "Don't GETC, Get Perl"; return "a"; }
</PRE>
<DT><STRONG><A NAME="item_DESTROY">DESTROY this</A></STRONG><P>
<DD>
As with the other types of ties, this method will be called when the tied
handle is about to be destroyed. This is useful for debugging and possibly
for cleaning up.
<P>
<PRE> sub DESTROY {
print "</shout>\n";
}
</PRE>
</DL>
<P>
<HR>
<H2><A NAME="Malloc_enhancements">Malloc enhancements</A></H2>
<P>
If perl is compiled with the malloc included with the perl distribution
(that is, if <CODE>perl -V:d_mymalloc</CODE> is 'define') then you can print memory statistics at runtime by running
Perl thusly:
<P>
<PRE> env PERL_DEBUG_MSTATS=2 perl your_script_here
</PRE>
<P>
The value of 2 means to print statistics after compilation and on exit;
with a value of 1, the statistics are printed only on exit. (If you want
the statistics at an arbitrary time, you'll need to install the optional
module Devel::Peek.)
<P>
Three new compilation flags are recognized by malloc.c. (They have no effect if perl is compiled with system
<CODE>malloc().)</CODE>
<DL>
<DT><STRONG><A NAME="item__DPERL_EMERGENCY_SBRK">-DPERL_EMERGENCY_SBRK</A></STRONG><P>
<DD>
If this macro is defined, running out of memory need not be a fatal error:
a memory pool can allocated by assigning to the special variable <CODE>$^M</CODE>. See <A HREF="#_M">$^M</A>.
<P><DT><STRONG><A NAME="item__DPACK_MALLOC">-DPACK_MALLOC</A></STRONG><P>
<DD>
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>
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><DT><STRONG><A NAME="item__DTWO_POT_OPTIMIZE">-DTWO_POT_OPTIMIZE</A></STRONG><P>
<DD>
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
<FONT SIZE=-1>16K</FONT> by default). Such allocations are typical for big hashes and special-purpose scripts, especially image processing.
<P>
On recent systems, the fact that perl requires
<FONT SIZE=-1>2M</FONT> from system for
<FONT SIZE=-1>1M</FONT> 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>
Expected saving of memory is 0-100% (100% in applications which require
most memory in such 2**n chunks); expected slowdown is negligible.
</DL>
<P>
<HR>
<H2><A NAME="Miscellaneous_efficiency_enhance">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>
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>
<HR>
<H1><A NAME="Support_for_More_Operating_Syste">Support for More Operating Systems</A></H1>
<P>
Support for the following operating systems is new in Perl 5.004.
<P>
<HR>
<H2><A NAME="Win32">Win32</A></H2>
<P>
Perl 5.004 now includes support for building a ``native'' perl under Windows
<FONT SIZE=-1>NT,</FONT> using the Microsoft Visual
<FONT SIZE=-1>C++</FONT> compiler (versions 2.0 and above) or the Borland
<FONT SIZE=-1>C++</FONT> 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
<FONT SIZE=-1>NT).</FONT> This port includes support for perl extension building tools like
<U>the MakeMaker manpage</U><!--../lib/ExtUtils/MakeMaker.html--> and <U>the h2xs manpage</U><!--../utils/h2xs.html-->, so that many extensions available on the Comprehensive Perl Archive Network
<FONT SIZE=-1>(CPAN)</FONT> can now be readily built under Windows
<FONT SIZE=-1>NT.</FONT> See <A HREF="http://www.perl.com/">http://www.perl.com/</A> for more information on
<FONT SIZE=-1>CPAN</FONT> and
<EM>README.win32</EM> in the perl distribution for more details on how to get started with
building this port.
<P>
There is also support for building perl under the Cygwin32 environment. Cygwin32 is a set of
<FONT SIZE=-1>GNU</FONT> tools that make it possible to compile and run many
<FONT SIZE=-1>UNIX</FONT> programs under Windows
<FONT SIZE=-1>NT</FONT> 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>
<HR>
<H2><A NAME="Plan_9">Plan 9</A></H2>
<P>
See <EM>README.plan9</EM> in the perl distribution.
<P>
<HR>
<H2><A NAME="QNX">QNX</A></H2>
<P>
See <EM>README.qnx</EM> in the perl distribution.
<P>
<HR>
<H2><A NAME="AmigaOS">AmigaOS</A></H2>
<P>
See <EM>README.amigaos</EM> in the perl distribution.
<P>
<HR>
<H1><A NAME="Pragmata">Pragmata</A></H1>
<P>
Six new pragmatic modules exist:
<DL>
<DT><STRONG>use autouse MODULE => qw(sub1 sub2 sub3)</STRONG><P>
<DD>
Defers <CODE>require MODULE</CODE> until someone calls one of the specified subroutines (which must be exported by
<FONT SIZE=-1>MODULE).</FONT> This pragma should be used with caution, and only when necessary.
<P><DT><STRONG>use blib</STRONG><DD>
<DT><STRONG>use blib 'dir'</STRONG><P>
<DD>
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>
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><DT><STRONG>use constant NAME => VALUE</STRONG><P>
<DD>
Provides a convenient interface for creating compile-time constants, See [perlman:perlsub].
<P><DT><STRONG>use locale</STRONG><P>
<DD>
Tells the compiler to enable (or disable) the use of
<FONT SIZE=-1>POSIX</FONT> locales for builtin operations.
<P>
When <CODE>use locale</CODE> is in effect, the current
<FONT SIZE=-1>LC_CTYPE</FONT> locale is used for regular expressions and case mapping;
<FONT SIZE=-1>LC_COLLATE</FONT> for string ordering; and
<FONT SIZE=-1>LC_NUMERIC</FONT> for numeric formating in printf and sprintf (but
<STRONG>not</STRONG> in print).
<FONT SIZE=-1>LC_NUMERIC</FONT> is always used in write, since lexical
scoping of formats is problematic at best.
<P>
Each <CODE>use locale</CODE> or <CODE>no locale</CODE> affects statements to the end of the enclosing
<FONT SIZE=-1>BLOCK</FONT> or, if not inside a
<FONT SIZE=-1>BLOCK,</FONT> to the end of the current file. Locales can be switched and queried with POSIX::setlocale().
<P>
See [perlman:perllocale|the perllocale manpage] for more information.
<P><DT><STRONG>use ops</STRONG><P>
<DD>
Disable unsafe opcodes, or any named opcodes, when compiling Perl code.
<P><DT><STRONG>use vmsish</STRONG><P>
<DD>
Enable VMS-specific language features. Currently, there are three
VMS-specific features available: 'status', which makes <CODE>$?</CODE> and
[perlfunc:system|system] return genuine
<FONT SIZE=-1>VMS</FONT> status values instead of emulating
<FONT SIZE=-1>POSIX;</FONT> 'exit', which makes
[perlfunc:exit|exit] take a genuine
<FONT SIZE=-1>VMS</FONT> 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
<FONT SIZE=-1>VMS</FONT> tradition.
</DL>
<P>
<HR>
<H1><A NAME="Modules">Modules</A></H1>
<P>
<HR>
<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>
<HR>
<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>
<HR>
<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 ("Common Gateway Interface")
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>
<P>
<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>
<P>
<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>
<P>
<PRE> Opcode.pm Disable named opcodes when compiling Perl code
</PRE>
<P>
<PRE> ExtUtils/Embed.pm Utilities for embedding Perl in C programs
ExtUtils/testlib.pm Fixes up @INC to use just-built extension
</PRE>
<P>
<PRE> FindBin.pm Find path of currently executing program
</PRE>
<P>
<PRE> Class/Struct.pm Declare struct-like datatypes as Perl classes
File/stat.pm By-name interface to Perl's builtin stat
Net/hostent.pm By-name interface to Perl's builtin gethost*
Net/netent.pm By-name interface to Perl's builtin getnet*
Net/protoent.pm By-name interface to Perl's builtin getproto*
Net/servent.pm By-name interface to Perl's builtin getserv*
Time/gmtime.pm By-name interface to Perl's builtin gmtime
Time/localtime.pm By-name interface to Perl's builtin localtime
Time/tm.pm Internal object for Time::{gm,local}time
User/grent.pm By-name interface to Perl's builtin getgr*
User/pwent.pm By-name interface to Perl's builtin getpw*
</PRE>
<P>
<PRE> Tie/RefHash.pm Base class for tied hashes with references as keys
</PRE>
<P>
<PRE> UNIVERSAL.pm Base class for *ALL* classes
</PRE>
<P>
<HR>
<H2><A NAME="Fcntl">Fcntl</A></H2>
<P>
New constants in the existing Fcntl modules are now supported, provided
that your operating system happens to support them:
<P>
<PRE> F_GETOWN F_SETOWN
O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
O_EXLOCK O_SHLOCK
</PRE>
<P>
These constants are intended for use with the Perl operators
<CODE>sysopen()</CODE> and
<CODE>fcntl()</CODE> and the basic database modules like SDBM_File. For the exact meaning of these and other Fcntl constants please refer to your operating system's documentation for
<CODE>fcntl()</CODE> and
<CODE>open().</CODE>
<P>
In addition, the Fcntl module now provides these constants for use with the Perl operator
<CODE>flock():</CODE>
<P>
<PRE> LOCK_SH LOCK_EX LOCK_NB LOCK_UN
</PRE>
<P>
These constants are defined in all environments (because where there is no
<CODE>flock()</CODE> system call, Perl
emulates it). However, for historical reasons, these constants are not
exported unless they are explicitly requested with the ``:flock'' tag (e.g. <CODE>use Fcntl ':flock'</CODE>).
<P>
<HR>
<H2><A NAME="IO">IO</A></H2>
<P>
The
<FONT SIZE=-1>IO</FONT> module provides a simple mechanism to load all of the
<FONT SIZE=-1>IO</FONT> modules at one go. Currently this includes:
<P>
<PRE> IO::Handle
IO::Seekable
IO::File
IO::Pipe
IO::Socket
</PRE>
<P>
For more information on any of these modules, please see its respective
documentation.
<P>
<HR>
<H2><A NAME="Math_Complex">Math::Complex</A></H2>
<P>
The Math::Complex module has been totally rewritten, and now supports more
operations. These are overloaded:
<P>
<PRE> + - * / ** <=> neg ~ abs sqrt exp log sin cos atan2 "" (stringify)
</PRE>
<P>
And these functions are now exported:
<P>
<PRE> pi i Re Im arg
log10 logn ln cbrt root
tan
csc sec cot
asin acos atan
acsc asec acot
sinh cosh tanh
csch sech coth
asinh acosh atanh
acsch asech acoth
cplx cplxe
</PRE>
<P>
<HR>
<H2><A NAME="Math_Trig">Math::Trig</A></H2>
<P>
This new module provides a simpler interface to parts of Math::Complex for
those who need trigonometric functions only for real numbers.
<P>
<HR>
<H2><A NAME="DB_File">DB_File</A></H2>
<P>
There have been quite a few changes made to DB_File. Here are a few of the
highlights:
<UL>
<LI>
<P>
Fixed a handful of bugs.
<P><LI>
By public demand, added support for the standard hash function
<CODE>exists().</CODE>
<P><LI>
Made it compatible with Berkeley
<FONT SIZE=-1>DB</FONT> 1.86.
<P><LI>
Made negative subscripts work with
<FONT SIZE=-1>RECNO</FONT> interface.
<P><LI>
Changed the default flags from
<FONT SIZE=-1>O_RDWR</FONT> to
<FONT SIZE=-1>O_CREAT|O_RDWR</FONT> and the default mode from 0640 to 0666.
<P><LI>
Made DB_File automatically import the
<CODE>open()</CODE> constants
<FONT SIZE=-1>(O_RDWR,</FONT>
<FONT SIZE=-1>O_CREAT</FONT> etc.) from Fcntl, if available.
<P><LI>
Updated documentation.
</UL>
<P>
Refer to the
<FONT SIZE=-1>HISTORY</FONT> section in DB_File.pm for a complete list of
changes. Everything after DB_File 1.01 has been added since 5.003.
<P>
<HR>
<H2><A NAME="Net_Ping">Net::Ping</A></H2>
<P>
Major rewrite - support added for both udp echo and real icmp pings.
<P>
<HR>
<H2><A NAME="Object_oriented_overrides_for_bu">Object-oriented overrides for builtin operators</A></H2>
<P>
Many of the Perl builtins returning lists now have object-oriented
overrides. These are:
<P>
<PRE> [perlman:File::stat|File::stat]
Net::hostent
Net::netent
Net::protoent
Net::servent
Time::gmtime
Time::localtime
User::grent
User::pwent
</PRE>
<P>
For example, you can now say
<P>
<PRE> use [perlman:File::stat|File::stat];
use User::pwent;
$his = (stat($filename)->st_uid == pwent($whoever)->pw_uid);
</PRE>
<P>
<HR>
<H1><A NAME="Utility_Changes">Utility Changes</A></H1>
<P>
<HR>
<H2><A NAME="pod2html">pod2html</A></H2>
<DL>
<DT><STRONG><A NAME="item_Sends">Sends converted HTML to standard output</A></STRONG><P>
<DD>
The <EM>pod2html</EM> utility included with Perl 5.004 is entirely new. By default, it sends the converted
<FONT SIZE=-1>HTML</FONT> to its standard output, instead of writing it to a file like Perl 5.003's
<EM>pod2html</EM> did. Use the <STRONG>--outfile=FILENAME</STRONG> option to write to a file.
</DL>
<P>
<HR>
<H2><A NAME="xsubpp">xsubpp</A></H2>
<DL>
<DT><STRONG><A NAME="item_void">void XSUBs now default to returning nothing</A></STRONG><P>
<DD>
Due to a documentation/implementation bug in previous versions of Perl,
XSUBs with a return type of [perlman:perlguts] have actually been returning one value. Usually that value was the
<FONT SIZE=-1>GV</FONT> for the
<FONT SIZE=-1>XSUB,</FONT> but sometimes it was some already freed or reused value, which would sometimes lead to program failure.
<P>
In Perl 5.004, if an
<FONT SIZE=-1>XSUB</FONT> is declared as returning [perlman:perlguts], it actually returns no value, i.e. an empty list (though there is a backward-compatibility exception; see below). If your
<FONT SIZE=-1>XSUB</FONT> really does return an
<FONT SIZE=-1>SV,</FONT> you should give it a return type of
[perlman:perlguts].
<P>
For backward compatibility, <EM>xsubpp</EM> tries to guess whether a
[perlman:perlguts]
<FONT SIZE=-1>XSUB</FONT> is really [perlman:perlguts] or if it wants to return an [perlman:perlguts]. It does so by examining the text of the
<FONT SIZE=-1>XSUB:</FONT> if <EM>xsubpp</EM> finds what looks like an assignment to [perlman:perlguts], it assumes that the XSUB's return type is really [perlman:perlguts].
</DL>
<P>
<HR>
<H1><A NAME="C_Language_API_Changes">C Language API Changes</A></H1>
<DL>
<DT><STRONG><A NAME="item_gv_fetchmethod">gv_fetchmethod and perl_call_sv</A></STRONG><P>
<DD>
The [perlman:perlguts] function finds a method for an object, just like in Perl 5.003. The
<FONT SIZE=-1>GV</FONT> it returns may be a method cache entry. However, in
Perl 5.004, method cache entries are not visible to users; therefore, they
can no longer be passed directly to [perlman:perlguts]. Instead, you should use the <CODE>GvCV</CODE> macro on the
<FONT SIZE=-1>GV</FONT> to extract its
<FONT SIZE=-1>CV,</FONT> and pass the
<FONT SIZE=-1>CV</FONT> to
[perlman:perlguts].
<P>
The most likely symptom of passing the result of [perlman:perlguts] to
[perlman:perlguts] is Perl's producing an ``Undefined subroutine called'' error on the <EM>second</EM> call to a given method (since there is no cache on the first call).
<P><DT><STRONG><A NAME="item_perl_eval_pv">perl_eval_pv</A></STRONG><P>
<DD>
<FONT SIZE=-1>A</FONT> new function handy for eval'ing strings of Perl code inside
<FONT SIZE=-1>C</FONT> code. This function returns the value from the eval statement, which can be used instead of fetching globals from the symbol table. See
[perlman:perlguts|the perlguts manpage], [perlman:perlembed|the perlembed manpage] and [perlman:perlcall|the perlcall manpage] for details and examples.
<P><DT><STRONG><A NAME="item_Extended">Extended API for manipulating hashes</A></STRONG><P>
<DD>
Internal handling of hash keys has changed. The old hashtable
<FONT SIZE=-1>API</FONT> is still fully supported, and will likely remain so. The additions to the
<FONT SIZE=-1>API</FONT> allow passing keys as
[perlman:perlguts]s, so that <CODE>tied</CODE> hashes can be given real scalars as keys rather than plain strings (nontied
hashes still can only use strings as keys). New extensions must use the new
hash access functions and macros if they wish to use [perlman:perlguts] keys. These additions also make it feasible to manipulate <CODE>HE*</CODE>s (hash entries), which can be more efficient. See [perlman:perlguts|the perlguts manpage] for details.
</DL>
<P>
<HR>
<H1><A NAME="Documentation_Changes">Documentation Changes</A></H1>
<P>
Many of the base and library pods were updated. These new pods are included
in section 1:
<DL>
<DT><STRONG><A NAME="item_perldelta">perldelta</A></STRONG><P>
<DD>
This document.
<P><DT><STRONG><A NAME="item_perlfaq">perlfaq</A></STRONG><P>
<DD>
Frequently asked questions.
<P><DT><STRONG><A NAME="item_perllocale">perllocale</A></STRONG><P>
<DD>
Locale support (internationalization and localization).
<P><DT><STRONG><A NAME="item_perltoot">perltoot</A></STRONG><P>
<DD>
Tutorial on Perl
<FONT SIZE=-1>OO</FONT> programming.
<P><DT><STRONG><A NAME="item_perlapio">perlapio</A></STRONG><P>
<DD>
Perl internal
<FONT SIZE=-1>IO</FONT> abstraction interface.
<P><DT><STRONG><A NAME="item_perlmodlib">perlmodlib</A></STRONG><P>
<DD>
Perl module library and recommended practice for module creation. Extracted
from [perlman:perlmod|the perlmod manpage] (which is much smaller as a result).
<P><DT><STRONG><A NAME="item_perldebug">perldebug</A></STRONG><P>
<DD>
Although not new, this has been massively updated.
<P><DT><STRONG><A NAME="item_perlsec">perlsec</A></STRONG><P>
<DD>
Although not new, this has been massively updated.
</DL>
<P>
<BR>[perlman:perl5004delta2|More...]<BR>
<BR>Return to the [Library]<BR>