perldelta - what's new for perl5.005
This document describes differences between the 5.004 release and this one.
[XXX this needs more verbose summaries of the sub topics, instead of just the "See foo." Scheduled for a second iteration. GSAR]
Starting with Perl 5.004_50 there were many deep and far-reaching changes to the language internals. If you have dynamically loaded extensions that you built under perl 5.003 or 5.004, you can continue to use them with 5.004, but you will need to rebuild and reinstall those extensions to use them 5.005. See INSTALL for detailed instructions on how to upgrade.
The new Configure defaults are designed to allow a smooth upgrade from 5.004 to 5.005, but you should read INSTALL for a detailed discussion of the changes in order to adapt them to your system.
When none of the experimental features are enabled, there should be no user-visible Perl source compatibility issue.
If threads are enabled, then some caveats apply. @_ and $_ become lexical variables. The effect of this should be largely transparent to the user, but there are some boundary conditions under which user will need to be aware of the issues. [XXX Add e.g. here.]
@_
$_
Some new keywords have been introduced. These are generally expected to have very little impact on compatibility. See "New INIT keyword", "New lock keyword", and "New qr// operator".
INIT
lock
qr//
Certain barewords are now reserved. Use of these will provoke a warning if you have asked for them with the -w switch. See "our is now a reserved word".
-w
our
This version is NOT binary compatible with older versions. All extensions will need to be recompiled.
A few taint leaks and taint omissions have been corrected. This may lead to "failure" of scripts that used to work with older versions. Compiling with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes to the tainting behavior. But note that the resulting perl will have known insecurities.
Oneliners with the -e switch do not create temporary files anymore.
-e
Many new warnings that were introduced in 5.004 have been made optional. Some of these warnings are still present, but perl's new features make them less often a problem. See "New Diagnostics".
Perl has a new Social Contract for contributors. See Porting/Contract.
The license included in much of the Perl documentation has changed. [XXX See where?]
WARNING: Threading is considered an experimental feature. Details of the implementation may change without notice. There are known limitations and and some bugs.
See README.threads.
WARNING: The Compiler and related tools are considered experimental. Features may change without notice, and there are known limitations and bugs.
The Compiler produces three different types of transformations of a perl program. The C backend generates C code that captures perl's state just before execution begins. It eliminates the compile-time overheads of the regular perl interpreter, but the run-time performance remains comparatively the same. The CC backend generates optimized C code equivivalent to the code path at run-time. The CC backend has greater potential for big optimizations, but only a few optimizations are implemented currently. The Bytecode backend generates a platform independent bytecode representation of the interpreter's state just before execution. Thus, the Bytecode back end also eliminates much of the compilation overhead of the interpreter.
The compiler comes with several valuable utilities.
B::Lint is an experimental module to detect and warn about suspicious code, especially the cases that the -w switch does not detect.
B::Lint
B::Deparse can be used to demystify perl code, and understand how perl optimizes certain constructs.
B::Deparse
B::Xref generates cross reference reports of all definition and use of variables, subroutines and formats in a program.
B::Xref
B::Showlex show the lexical variables used by a subroutine or file at a glance.
B::Showlex
perlcc is a simple frontend for compiling perl.
perlcc
See ext/B/README.
ext/B/README
See perlre and perlop.
See banner at the beginning of malloc.c for details.
malloc.c
See perlfunc/sort.
perlfunc/sort
Two kinds.
Via Thread::Signal.
Thread::Signal
Via switched runtime op loop. [XXX Not yet available.]
The internals now reallocate the perl stack only at predictable times. In particular, magic calls never trigger reallocations of the stack, because all reentrancy of the runtime is handled using a "stack of stacks". This should improve reliability of cached stack pointers in the internals and in XSUBs.
See "local" in perlfunc.
%!
See perlvar, and Errno.
See perlref.
EXPR foreach EXPR
See perlsyn.
[XXX See what?]
See perlsub.
$^E
See perlvar.
foreach (1..1000000)
foreach (1..1000000) is now optimized into a counting loop. It does not try to allocate a 1000000-size list anymore.
Foo::
exists $Foo::{Bar::}
See perllocale.
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.
See "prototype" in perlfunc.
die() now accepts a reference value, and $@ gets set to that value in exception traps. This makes it possible to propagate exception objects. See "eval" in perlfunc. [XXX there's nothing about this in perlfunc/eval yet.]
die()
$@
See "Destructors" in perlobj.
printf
See "printf" in perlfunc.
INIT subs are like BEGIN and END, but they get run just before the perl runtime begins execution. e.g., the Perl Compiler makes use of INIT blocks to initialize and resolve pointers to XSUBs.
BEGIN
END
[XXX Needs to be documented in perlsub or perlmod.]
The lock keyword is the fundamental synchronization primitive in threaded perl. When threads are not enabled, it is currently a noop.
To minimize impact on source compatibility this keyword is "weak", i.e., any user-defined subroutine of the same name overrides it, unless a use Thread has been seen.
use Thread
The qr// 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 perlop.
See Tie::Array.
Several missing hooks have been added. There is also a new base class for TIEARRAY implementations. See Tie::Array.
substr() can now both return and replace in one operation. The optional 4th argument is the replacement string. See "substr" in perlfunc.
Splice() with a negative LENGTH argument now work similar to what the LENGTH did for substr(). Previously a negative LENGTH was treated as 0. See "splice" in perlfunc.
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 config.sh.
BeOS is now supported. See README.beos.
DOS is now supported under the DJGPP tools. See README.dos.
MPE/iX is now supported. See README.mpeix.
Win32 support has been vastly enhanced. Support for Perl Object, a C++ encapsulation of Perl. GCC and EGCS are now supported on Win32. [XXX Perl Object needs a big explanation elsewhere, and a pointer to that location here.]
VMS configuration system has been rewritten. See README.vms.
OpenBSD better supported. [XXX what others?]
Perl compiler and tools. See [XXX what?].
A module to pretty print Perl data. See Data::Dumper.
A module to look up errors more conveniently. See Errno.
A portable API for file operations.
Query and manage installed modules.
Manipulate .packlist files.
Make functions/builtins succeed or die.
Constants and other support infrastructure for System V IPC operations in perl.
A framework for writing testsuites.
Base class for tied arrays.
Base class for tied handles.
Perl thread creation, manipulation, and support.
Set subroutine attributes.
Compile-time class fields.
Various pragmata to control behavior of regular expressions.
CGI has been updated to version 2.42.
POSIX now has its own platform-specific hints files.
DB_File supports version 2.x of Berkeley DB. See ext/DB_File/Changes.
ext/DB_File/Changes
MakeMaker now supports writing empty makefiles, provides a way to specify that site umask() policy should be honored. There is also better support for manipulation of .packlist files, and getting information about installed modules.
Extensions that have both architecture-dependent and architecture-independent files are now always installed completely in the architecture-dependent locations. Previously, the shareable parts were shared both across architectures and across perl versions and were therefore liable to be overwritten with newer versions that might have subtle incompatibilities.
[XXX What?]
Cwd::cwd is faster on most platforms.
Keeps better time.
h2ph and related utilities have been vastly overhauled.
perlcc, a new experimental front end for the compiler is available.
The crude GNU configure emulator is now called configure.gnu.
Config.pm now has a glossary of variables.
Porting/patching.pod has detailed instructions on how to create and submit patches for perl.
(W) A subroutine you have declared has the same name as a Perl keyword, and you have used the name without qualification for calling one or the other. Perl decided to call the builtin because the subroutine is not imported.
To force interpretation as a subroutine call, either put an ampersand before the subroutine name, or qualify the name with its package. Alternatively, you can import the subroutine (or pretend that it's imported with the use subs pragma).
use subs
To silently interpret it as the Perl operator, use the CORE:: prefix on the operator (e.g. CORE::log($x)) or by declaring the subroutine to be an object method (see attrs).
CORE::
CORE::log($x)
(F) The index looked up in the hash found as the 0'th element of a pseudo-hash is not legal. Index values must be at 1 or greater. See perlref.
(W) You used a qualified bareword of the form Foo::, but the compiler saw no other uses of that namespace before that point. Perhaps you need to predeclare a package?
(F) You used the syntax of a method call, but the slot filled by the object reference or package name contains an undefined value. Something like this will reproduce the error:
$BADREF = 42; process $BADREF 1,2,3; $BADREF->process(1,2,3);
(F) You used an array where a hash was expected, but the array has no information on how to map from keys to array indices. You can do that only with arrays that have a hash reference at index 0.
(F) The "goto subroutine" call can't be used to jump out of an eval "string". (You can use it to jump out of an eval {BLOCK}, but you probably don't want to.)
(F) The first time the %! hash is used, perl automatically loads the Errno.pm module. The Errno module is expected to tie the %! hash to provide symbolic names for $! errno values.
$!
(F) A string of a form CORE::word was given to prototype(), but there is no builtin with the name word.
CORE::word
word
(W) Within regular expression character classes ([]) the syntax beginning with "[." and ending with ".]" is reserved for future extensions. If you need to represent those character sequences inside a regular expression character class, just quote the square brackets with the backslash: "\[." and ".\]".
(W) Within regular expression character classes ([]) the syntax beginning with "[:" and ending with ":]" is reserved for future extensions. If you need to represent those character sequences inside a regular expression character class, just quote the square brackets with the backslash: "\[:" and ":\]".
(W) Within regular expression character classes ([]) the syntax beginning with "[=" and ending with "=]" is reserved for future extensions. If you need to represent those character sequences inside a regular expression character class, just quote the square brackets with the backslash: "\[=" and "=\]".
(F) Perl detected tainted data when trying to compile a regular expression that contains the (?{ ... }) zero-width assertion, which is unsafe. See "(?{ code })" in perlre, and perlsec.
(?{ ... })
(F) A regular expression contained the (?{ ... }) zero-width assertion, but that construct is only allowed when the use re 'eval' pragma is in effect. See "(?{ code })" in perlre.
use re 'eval'
(F) Perl tried to compile a regular expression containing the (?{ ... }) zero-width assertion at run time, as it would when the pattern contains interpolated values. Since that is a security risk, it is not allowed. If you insist, you may still do this by explicitly building the pattern from an interpolated string at run time and using that in an eval(). See "(?{ code })" in perlre.
(W) You are blessing a reference to a zero length string. This has the effect of blessing the reference into the package main. This is usually not what you want. Consider providing a default target package, e.g. bless($ref, $p or 'MyPackage');
(W) You may have tried to use a character other than 0 - 9 or A - F in a hexadecimal number. Interpretation of the hexadecimal number stopped before the illegal character.
(F) You tried to access an array as a hash, but the field name used is not defined. The hash at index 0 should map all valid field names to array indices for that to work.
(F) You tried to access a field of a typed variable where the type does not know about the field name. The field names are looked up in the %FIELDS hash in the type package at compile time. The %FIELDS hash is usually set up with the 'fields' pragma.
(F) You can't allocate more than 2^31+"small amount" bytes. This error is most likely to be caused by a typo in the Perl program. e.g., $arr[time] instead of $arr[$time].
$arr[time]
$arr[$time]
(F) One (or both) of the numeric arguments to the range operator ".." are outside the range which can be represented by integers internally. One possible workaround is to force Perl to use magical string increment by prepending "0" to your numbers.
(F) More than 100 levels of inheritance were encountered while invoking a method. Probably indicates an unintended loop in your inheritance hierarchy.
(W) You gave a single reference where Perl was expecting a list with an even number of elements (for assignment to a hash). This usually means that you used the anon hash constructor when you meant to use parens. In any case, a hash requires key/value pairs.
%hash = { one => 1, two => 2, }; # WRONG %hash = [ qw/ an anon array / ]; # WRONG %hash = ( one => 1, two => 2, ); # right %hash = qw( one 1 two 2 ); # also fine
(W) An undefined value was assigned to a typeglob, a la *foo = undef. This does nothing. It's possible that you really mean undef *foo.
*foo = undef
undef *foo
(D) The indicated bareword is a reserved word. Future versions of perl may use it as a keyword, so you're better off either explicitly quoting the word in a manner appropriate for its context of use, or using a different name altogether. The warning can be suppressed for subroutine names by either adding a & prefix, or using a package qualifier, e.g. &our(), or Foo::our().
&
&our()
Foo::our()
(S) The whole warning message will look something like:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = "En_US", LANG = (unset) are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
Exactly what were the failed locale settings varies. In the above the settings were that the LC_ALL was "En_US" and the LANG had no value. This error means that Perl detected that you and/or your system administrator have set up the so-called variable system but Perl could not use those settings. This was not dead serious, fortunately: there is a "default locale" called "C" that Perl can and will use, the script will be run. Before you really fix the problem, however, you will get the same error message each time you run Perl. How to really fix the problem can be found in perllocale section LOCALE PROBLEMS.
(F) The mktemp() routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.
(F) The write routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.
(F) The create routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.
If you find what you think is a bug, you might check the headers of recently posted articles in the comp.lang.perl.misc newsgroup. There may also be information at http://www.perl.com/perl/, the Perl Home Page.
If you believe you have an unreported bug, please run the perlbug program included with your release. Make sure you trim your bug down to a tiny but sufficient test case. Your bug report, along with the output of perl -V, will be sent off to <perlbug@perl.com> to be analysed by the Perl porting team.
perl -V
The Changes file for exhaustive details on what changed.
The INSTALL file for how to build Perl.
The README file for general stuff.
The Artistic and Copying files for copyright information.
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
To install lib, copy and paste the appropriate command in to your terminal.
cpanm
cpanm lib
CPAN shell
perl -MCPAN -e shell install lib
For more information on module installation, please visit the detailed CPAN module installation guide.