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.

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.

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.
PERL5OPT may only be used to set the following switches:
-[DIMUdmw].

The -M and perlman:perlop options are no longer allowed on the #! line of a script. If a script needs a module, it should invoke it with the
use pragma.

The -T option is also forbidden on the #! line of a script, unless it was present on the Perl command line. Due to
the way #!
works, this usually means that -T must be in the first argument. Thus:

#!/usr/bin/perl -T -w

will probably work for an executable script invoked as scriptname, while:

#!/usr/bin/perl -w -T

will probably fail under the same conditions. (Non-Unix systems will
probably not follow this rule.) But perl scriptname is guaranteed to fail, since then there is no chance of -T being found on the command line before it is found on the #! line.

If you removed the -w 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.

Before Perl 5.004, AUTOLOAD functions were looked up as methods (using the @ISA hierarchy), even when the function to be autoloaded was called as a plain
function (e.g. Foo::bar()), not a method (e.g. Foo->bar() or $obj->bar()).

Perl 5.005 will use method lookup only for methods' AUTOLOADs. 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 AUTOLOAD.

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 AUTOLOAD for non-methods from a base class named
BaseClass, execute *AUTOLOAD = \&BaseClass::AUTOLOAD during startup.

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
the overload manpage for more details.

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 @_).

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.

The $) 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 getgroups()C function (if there is one). However, until this
release, there has not been a way to call the
setgroups()C function from Perl.

In Perl 5.004, assigning to $) 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
setgroups()C function (if there is one).

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.

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.

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.

The documentation for Perl 5.0 has always stated that $. is not
reset when an already-open file handle is reopened with no intervening call
to close. Due to a bug, perl versions 5.000 through 5.003
did reset $. under that circumstance; Perl 5.004 does not.

The wantarray operator returns true if a subroutine is expected to return a list, and
false otherwise. In Perl 5.004, 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.

Perl (version 5) used to determine the value of
EXPR inconsistently, sometimes incorrectly using the surrounding context for the determination. Now, the value of
EXPR (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:

@a = qw(time now is time);
print eval @a;
print '|', scalar eval @a;

used to print something like ``timenowis881399109|4'', but now (and in
perl4) prints ``4|4''.

A 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
-T 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.

These operators may spawn the
C 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.

No spawning if tainted $CDPATH, $ENV, $BASH_ENV

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 $IFS and
$PATH.

No spawning if tainted $TERM doesn't look like a terminal name

Some termcap libraries do unsafe things with
$TERM. However, it would be unnecessarily harsh to treat all $TERM values as unsafe, since only shell metacharacters can cause trouble in
$TERM. So a tainted $TERM is considered to be safe if it contains only alphanumerics, underscores, dashes, and colons, and unsafe if it contains other characters (including whitespace).

A new Opcode module supports the creation, manipulation and application of opcode masks. The revised Safe module has a new
API and is implemented using the new Opcode module. Please read the new Opcode and Safe documentation.

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
C program. See the updated perlembed manpage for tips on how to manage your interpreters.

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
IO::* modules -- specifically, IO::Handle, IO::Seekable, and IO::File. We suggest, but do not require, that you use the
IO::* modules in new code.

In harmony with this change, *GLOB{FILEHANDLE} is now just a backward-compatible synonym for *GLOB{IO}.

A 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).

This new syntax follows the pattern of $hashref->{FOO} and
$aryref->[$foo]: You may now write &$subref($foo) as
$subref->($foo). All of these arrow terms may be chained; thus, &{$table->{FOO}}($bar) may now be written
$table->{FOO}->($bar).

The current package name at compile time, or the undefined value if there
is no current package (due to a perlfunc:package directive). Like
__FILE__ and __LINE__, __PACKAGE__ does not interpolate into strings.

The current set of syntax checks enabled by use strict. See the documentation of strict for more details. Not actually new, but newly documented. Because it is
intended for internal use by Perl core components, there is no use English long name for this variable.

By default, running out of memory it is not trappable. However, if compiled
for this, Perl may use the contents of $^M as an emergency pool after
die()ing with this message. Suppose that your Perl were compiled with
-DPERL_EMERGENCY_SBRK and used Perl's malloc. Then

$^M = 'a' x (1<<16);

would allocate a
64K buffer for use when in emergency. See the INSTALL file for information on how to enable this option. As a disincentive to
casual use of this advanced feature, there is no use English long name for this variable.

Perl now implements these functions itself; it doesn't use the
C library function
sprintf() 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.

The new conversions in Perl's
sprintf() are:

%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

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.

As an lvalue, 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

keys %hash = 200;

then %hash will have at least 200 buckets allocated for it. These buckets will be
retained even if you do %hash = (); use undef
%hash if you want to free the storage while %hash is still in scope. You can't shrink the number of buckets allocated for the
hash using
keys in this way (but you needn't worry about doing this by accident, as trying
has no effect).

A new format 'w' represents a
BER compressed integer (as defined in
ASN.1). 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.

If 'p' or
'P' are given undef as values, they now generate a
NULL pointer.

Both
pack() and
unpack() now fail when their templates contain invalid types. (Invalid types used to be ignored.)

The new
sysseek() operator is a variant of
seek() that sets and gets the file's system read/write position, using the
lseek(2) system call. It is the only reliable way to seek before using
sysread() or
syswrite(). Its return value is the new position, or the undefined value on failure.

If the first argument to 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
VERSION, then an error message is printed and Perl exits immediately. Because
use occurs at compile time, this check happens immediately during the
compilation process, unlike require VERSION, which waits until runtime for the check. This is often useful if you need
to check the current Perl version before useing library modules which have changed in incompatible ways from older
versions of Perl. (We try not to do this more than we have to.)

use Module VERSION LIST

If the
VERSION argument is present between Module and
LIST, then the
use will call the
VERSION method in class Module with the given version as an argument. The default
VERSION method, inherited from the
UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION. (Note that there is not a comma after
VERSION!)

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.

Returns the prototype of a function as a string (or undef if the function has no prototype).
FUNCTION is a reference to or the name of the function
whose prototype you want to retrieve. (Not actually new; just never
documented before.)

The default seed for srand, which used to be 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.

Previous to version 5.004, calling rand without first calling srand
would yield the same sequence of random numbers on most or all machines.
Now, when perl sees that you're calling rand and haven't yet called
srand, it calls srand with the default seed. You should still call
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.

The m//g match iteration construct has always reset its target string's search
position (which is visible through the pos operator) when a match fails; as a result, the next m//g 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. m//gc. This feature, in conjunction with the \G zero-width assertion, makes it possible to chain matches together. See the perlop manpage
and the perlre manpage.

The m//x 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, /a *b/x was (mis)interpreted as /a\*b/x. This bug has been fixed in 5.004.

Just like anonymous functions that contain lexical variables that change
(like a lexical index variable for a foreach loop), formats now work properly. For example, this silently failed before
(printed only zeros), but is fine now:

my $i;
foreach $i ( 1 .. 10 ) {
write;
}
format =
my i is @#
$i
.

However, it still fails (without a warning) if the foreach is within a
subroutine:

VERSION returns the version number of the class (package). If the
NEED argument is given then it will check that the current version (as defined by the $VERSION variable in the given package) not less than
NEED; 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
VERSION form of use.

use A 1.2 qw(some imported subs);
# implies:
A->VERSION(1.2);

NOTE:can directly uses Perl's internal code for method lookup, and
isa uses a very similar method and caching strategy. This may cause strange
effects if the Perl code dynamically changes @ISA in any
package.

You may add other methods to the
UNIVERSAL class via Perl or
XS code. You do not need to
use UNIVERSAL in order to make these methods available to your program. This is necessary
only if you wish to have isa available as a plain subroutine in the current package.

If perl is compiled with the malloc included with the perl distribution
(that is, if perl -V:d_mymalloc is 'define') then you can print memory statistics at runtime by running
Perl thusly:

env PERL_DEBUG_MSTATS=2 perl your_script_here

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.)

Three new compilation flags are recognized by malloc.c. (They have no effect if perl is compiled with system
malloc().)

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 PACK_MALLOC 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).

Expected memory savings (with 8-byte alignment in alignbytes) 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).

Similarly to PACK_MALLOC, 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.

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.

Expected saving of memory is 0-100% (100% in applications which require
most memory in such 2**n chunks); expected slowdown is negligible.

Perl 5.004 now includes support for building a ``native'' 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
the MakeMaker manpage and the h2xs manpage, so that many extensions available on the Comprehensive Perl Archive Network
(CPAN) can now be readily built under Windows
NT. See http://www.perl.com/ for more information on
CPAN and
README.win32 in the perl distribution for more details on how to get started with
building this port.

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
README.cygwin32 in the perl distribution for more details on this port and how to obtain
the Cygwin32 toolkit.

Defers require MODULE 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.

use blib

use blib 'dir'

Looks for MakeMaker-like 'blib' directory structure starting in
dir (or current directory) and working back up to five levels of parent
directories.

Intended for use on command line with -M option as a way of testing arbitrary scripts against an uninstalled version
of a package.

use constant NAME => VALUE

Provides a convenient interface for creating compile-time constants, See perlman:perlsub.

use locale

Tells the compiler to enable (or disable) the use of
POSIX locales for builtin operations.

When use locale 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 formating in printf and sprintf (but
not in print).
LC_NUMERIC is always used in write, since lexical
scoping of formats is problematic at best.

Each use locale or no locale 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().

Disable unsafe opcodes, or any named opcodes, when compiling Perl code.

use vmsish

Enable VMS-specific language features. Currently, there are three
VMS-specific features available: 'status', which makes $? and
system return genuine
VMS status values instead of emulating
POSIX; 'exit', which makes
exit take a genuine
VMS status value instead of assuming that exit 1 is an error; and 'time', which makes all times relative to the local time zone, in the
VMS tradition.

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.

The installperl 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.

These constants are intended for use with the Perl operators
sysopen() and
fcntl() 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
fcntl() and
open().

In addition, the Fcntl module now provides these constants for use with the Perl operator
flock():

LOCK_SH LOCK_EX LOCK_NB LOCK_UN

These constants are defined in all environments (because where there is no
flock() 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. use Fcntl ':flock').

The pod2html utility included with Perl 5.004 is entirely new. By default, it sends the converted
HTML to its standard output, instead of writing it to a file like Perl 5.003's
pod2html did. Use the --outfile=FILENAME option to write to a file.

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
GV for the
XSUB, but sometimes it was some already freed or reused value, which would sometimes lead to program failure.

In Perl 5.004, if an
XSUB 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
XSUB really does return an
SV, you should give it a return type of
perlman:perlguts.

The perlman:perlguts function finds a method for an object, just like in Perl 5.003. The
GV 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 GvCV macro on the
GV to extract its
CV, and pass the
CV to
perlman:perlguts.

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 second call to a given method (since there is no cache on the first call).

Internal handling of hash keys has changed. The old hashtable
API is still fully supported, and will likely remain so. The additions to the
API allow passing keys as
perlman:perlgutss, so that tied 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 HE*s (hash entries), which can be more efficient. See the perlguts manpage for details.

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other