3 perldelta - what's new for perl5.005
7 This document describes differences between the 5.004 release and this one.
9 [XXX this needs more verbose summaries of the sub topics, instead of just
10 the "See L<foo>." Scheduled for a second iteration. GSAR]
12 =head1 About the new versioning system
14 =head1 Incompatible Changes
16 =head2 WARNING: This version is not binary compatible with Perl 5.004.
18 Starting with Perl 5.004_50 there were many deep and far-reaching changes
19 to the language internals. If you have dynamically loaded extensions
20 that you built under perl 5.003 or 5.004, you can continue to use them
21 with 5.004, but you will need to rebuild and reinstall those extensions
22 to use them 5.005. See L<INSTALL> for detailed instructions on how to
25 =head2 Default installation structure has changed
27 The new Configure defaults are designed to allow a smooth upgrade from
28 5.004 to 5.005, but you should read L<INSTALL> for a detailed
29 discussion of the changes in order to adapt them to your system.
31 =head2 Perl Source Compatibility
33 When none of the experimental features are enabled, there should be
34 no user-visible Perl source compatibility issue.
36 If threads are enabled, then some caveats apply. C<@_> and C<$_> become
37 lexical variables. The effect of this should be largely transparent to
38 the user, but there are some boundary conditions under which user will
39 need to be aware of the issues. [XXX Add e.g. here.]
41 Some new keywords have been introduced. These are generally expected to
42 have very little impact on compatibility. See L</New C<INIT> keyword>,
43 L</New C<lock> keyword>, and L</New C<qr//> operator>.
45 Certain barewords are now reserved. Use of these will provoke a warning
46 if you have asked for them with the C<-w> switch.
47 See L</C<our> is now a reserved word>.
49 =head2 C Source Compatibility
51 =item Core sources now require ANSI C compiler
53 =item Enabling threads has source compatibility issues
55 =head2 Binary Compatibility
57 This version is NOT binary compatible with older versions. All extensions
58 will need to be recompiled.
60 =head2 Security fixes may affect compatibility
62 A few taint leaks and taint omissions have been corrected. This may lead
63 to "failure" of scripts that used to work with older versions. Compiling
64 with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes
65 to the tainting behavior. But note that the resulting perl will have
68 Oneliners with the C<-e> switch do not create temporary files anymore.
70 =head2 Relaxed new mandatory warnings introduced in 5.004
72 Many new warnings that were introduced in 5.004 have been made
73 optional. Some of these warnings are still present, but perl's new
74 features make them less often a problem. See L<New Diagnostics>.
78 Perl has a new Social Contract for contributors. See F<Porting/Contract>.
80 The license included in much of the Perl documentation has changed.
88 WARNING: Threading is considered an experimental feature. Details of the
89 implementation may change without notice. There are known limitations
92 See L<README.threads>.
96 WARNING: The Compiler and related tools are considered experimental.
97 Features may change without notice, and there are known limitations
100 The Compiler produces three different types of transformations of a
101 perl program. The C backend generates C code that captures perl's state
102 just before execution begins. It eliminates the compile-time overheads
103 of the regular perl interpreter, but the run-time performance remains
104 comparatively the same. The CC backend generates optimized C code
105 equivivalent to the code path at run-time. The CC backend has greater
106 potential for big optimizations, but only a few optimizations are
107 implemented currently. The Bytecode backend generates a platform
108 independent bytecode representation of the interpreter's state
109 just before execution. Thus, the Bytecode back end also eliminates
110 much of the compilation overhead of the interpreter.
112 The compiler comes with several valuable utilities.
114 C<B::Lint> is an experimental module to detect and warn about suspicious
115 code, especially the cases that the C<-w> switch does not detect.
117 C<B::Deparse> can be used to demystify perl code, and understand
118 how perl optimizes certain constructs.
120 C<B::Xref> generates cross reference reports of all definition and use
121 of variables, subroutines and formats in a program.
123 C<B::Showlex> show the lexical variables used by a subroutine or file
126 C<perlcc> is a simple frontend for compiling perl.
130 =head2 Regular Expressions
132 See L<perlre> and L<perlop>.
134 =head2 Improved malloc()
136 See banner at the beginning of C<malloc.c> for details.
138 =head2 Quicksort is internally implemented
140 See C<perlfunc/sort>.
142 =head2 Reliable signals
146 Via C<Thread::Signal>.
148 Via switched runtime op loop. [XXX Not yet available.]
150 =head2 Reliable stack pointers
152 The internals now reallocate the perl stack only at predictable times.
153 In particular, magic calls never trigger reallocations of the stack,
154 because all reentrancy of the runtime is handled using a "stack of stacks".
155 This should improve reliability of cached stack pointers in the internals
158 =head2 Behavior of local() on composites is now well-defined
160 See L<perlfunc/local>.
162 =head2 C<%!> is transparently tied to the L<Errno> module
164 See L<perlvar>, and L<Errno>.
166 =head2 Pseudo-hashes are supported
170 =head2 C<EXPR foreach EXPR> is supported
174 =head2 Slice notation on glob elements is supported
178 =head2 Keywords can be globally overridden
182 =head2 C<$^E> is meaningful on Win32
186 =head2 C<foreach (1..1000000)> optimized
188 C<foreach (1..1000000)> is now optimized into a counting loop. It does
189 not try to allocate a 1000000-size list anymore.
191 =head2 C<Foo::> can be used as implicitly quoted package name
195 =head2 C<exists $Foo::{Bar::}> tests existence of a package
199 =head2 Better locale support
203 =head2 Experimental support for 64-bit platforms
205 Perl5 has always had 64-bit support on systems with 64-bit longs.
206 Starting with 5.005, the beginnings of experimental support for systems
207 with 32-bit long and 64-bit 'long long' integers has been added.
208 If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
209 define it in perl.h) then perl will be built with 'long long' support.
210 There will be many compiler warnings, and the resultant perl may not
211 work on all systems. There are many other issues related to
212 third-party extensions and libraries. This option exists to allow
213 people to work on those issues.
215 =head2 prototype() returns useful results on builtins
217 See L<perlfunc/prototype>.
219 =head2 Re-blessing in DESTROY() supported for chaining DESTROY() methods
221 See L<perlobj/Destructors>.
223 =head2 All C<printf> format conversions are handled internally
225 See L<perlfunc/printf>.
227 =head2 New C<INIT> keyword
229 C<INIT> subs are like C<BEGIN> and C<END>, but they get run just before
230 the perl runtime begins execution. e.g., the Perl Compiler makes use of
231 C<INIT> blocks to initialize and resolve pointers to XSUBs.
233 [XXX Needs to be documented in perlsub or perlmod.]
235 =head2 New C<lock> keyword
237 The C<lock> keyword is the fundamental synchronization primitive
238 in threaded perl. When threads are not enabled, it is currently a noop.
240 To minimize impact on source compatibility this keyword is "weak", i.e., any
241 user-defined subroutine of the same name overrides it, unless a C<use Thread>
244 =head2 New C<qr//> operator
246 The C<qr//> operator, which is syntactically similar to the other quote-like
247 operators, is used to create compiled regular expressions. This compiled
248 form can now be explicitly passed around in variables, and interpolated in
249 other regular expressions. See L<perlop> and L<perlre>.
251 =head2 C<our> is now a reserved word
253 =head2 Tied arrays are now fully supported
257 =head2 Tied handles support is better
259 Several missing hooks have been added. There is also a new base class for
260 TIEARRAY implementations. See L<Tie::Array>.
263 =head1 Supported Platforms
265 Configure has many incremental improvements. Site-wide policy for building
266 perl can now be made persistent, via Policy.sh. Configure also records
267 the command-line arguments used in F<config.sh>.
271 BeOS is now supported. See L<README.beos>.
273 DOS is now supported under the DJGPP tools. See L<README.dos>.
275 =head2 Changes in existing support
277 Win32 support has been vastly enhanced. Support for Perl Object, a C++
278 encapsulation of Perl. GCC and EGCS are now supported on Win32.
279 [XXX Perl Object needs a big explanation elsewhere, and a pointer to
282 VMS configuration system has been rewritten. See L<README.vms>.
284 OpenBSD better supported. [XXX what others?]
286 =head1 Modules and Pragmata
294 Perl compiler and tools. See [XXX what?].
298 A module to pretty print Perl data. See L<Data::Dumper>.
302 A module to look up errors more conveniently. See L<Errno>.
306 A portable API for file operations.
308 =item ExtUtils::Installed
310 Query and manage installed modules.
312 =item ExtUtils::Packlist
314 Manipulate .packlist files.
318 Make functions/builtins succeed or die.
322 Constants and other support infrastructure for System V IPC operations
327 A framework for writing testsuites.
331 Base class for tied arrays.
335 Base class for tied handles.
339 Perl thread creation, manipulation, and support.
343 Set subroutine attributes.
347 Compile-time class fields.
351 Various pragmata to control behavior of regular expressions.
355 =head2 Changes in existing modules
361 CGI has been updated to version 2.42.
365 POSIX now has its own platform-specific hints files.
369 DB_File supports version 2.x of Berkeley DB. See C<ext/DB_File/Changes>.
373 MakeMaker now supports writing empty makefiles, provides a way to
374 specify that site umask() policy should be honored. There is also
375 better support for manipulation of .packlist files, and getting
376 information about installed modules.
378 Extensions that have both architecture-dependent and
379 architecture-independent files are now always installed completely in
380 the architecture-dependent locations. Previously, the shareable parts
381 were shared both across architectures and across perl versions and were
382 therefore liable to be overwritten with newer versions that might have
383 subtle incompatibilities.
391 Cwd::cwd is faster on most platforms.
399 =head1 Utility Changes
401 h2ph and related utilities have been vastly overhauled.
403 perlcc, a new experimental front end for the compiler is available.
405 The crude GNU configure emulator is now called configure.gnu.
409 =head2 Incompatible Changes
411 =head2 Deprecations, Extensions
415 =head1 Documentation Changes
417 Config.pm now has a glossary of variables.
419 Porting/patching.pod has detailed instructions on how to create and
420 submit patches for perl.
422 =head1 New Diagnostics
426 =item Ambiguous call resolved as CORE::%s(), qualify as such or use &
428 (W) A subroutine you have declared has the same name as a Perl keyword,
429 and you have used the name without qualification for calling one or the
430 other. Perl decided to call the builtin because the subroutine is
433 To force interpretation as a subroutine call, either put an ampersand
434 before the subroutine name, or qualify the name with its package.
435 Alternatively, you can import the subroutine (or pretend that it's
436 imported with the C<use subs> pragma).
438 To silently interpret it as the Perl operator, use the C<CORE::> prefix
439 on the operator (e.g. C<CORE::log($x)>) or by declaring the subroutine
440 to be an object method (see L<attrs>).
442 =item Bad index while coercing array into hash
444 (F) The index looked up in the hash found as the 0'th element of a
445 pseudo-hash is not legal. Index values must be at 1 or greater.
448 =item Bareword "%s" refers to nonexistent package
450 (W) You used a qualified bareword of the form C<Foo::>, but
451 the compiler saw no other uses of that namespace before that point.
452 Perhaps you need to predeclare a package?
454 =item Can't call method "%s" on an undefined value
456 (F) You used the syntax of a method call, but the slot filled by the
457 object reference or package name contains an undefined value.
458 Something like this will reproduce the error:
461 process $BADREF 1,2,3;
462 $BADREF->process(1,2,3);
464 =item Can't coerce array into hash
466 (F) You used an array where a hash was expected, but the array has no
467 information on how to map from keys to array indices. You can do that
468 only with arrays that have a hash reference at index 0.
470 =item Can't goto subroutine from an eval-string
472 (F) The "goto subroutine" call can't be used to jump out of an eval "string".
473 (You can use it to jump out of an eval {BLOCK}, but you probably don't want to.)
475 =item Can't use %%! because Errno.pm is not available
477 (F) The first time the %! hash is used, perl automatically loads the
478 Errno.pm module. The Errno module is expected to tie the %! hash to
479 provide symbolic names for C<$!> errno values.
481 =item Can't use %%! because Errno.pm is not available
483 (F) The first time the %! hash is used, perl automatically loads the
484 Errno.pm module. The Errno module is expected to tie the %! hash to
485 provide symbolic names for C<$!> errno values.
487 =item Cannot find an opnumber for "%s"
489 (F) A string of a form C<CORE::word> was given to prototype(), but
490 there is no builtin with the name C<word>.
492 =item Character class syntax [. .] is reserved for future extensions
494 (W) Within regular expression character classes ([]) the syntax beginning
495 with "[." and ending with ".]" is reserved for future extensions.
496 If you need to represent those character sequences inside a regular
497 expression character class, just quote the square brackets with the
498 backslash: "\[." and ".\]".
500 =item Character class syntax [: :] is reserved for future extensions
502 (W) Within regular expression character classes ([]) the syntax beginning
503 with "[:" and ending with ":]" is reserved for future extensions.
504 If you need to represent those character sequences inside a regular
505 expression character class, just quote the square brackets with the
506 backslash: "\[:" and ":\]".
508 =item Character class syntax [= =] is reserved for future extensions
510 (W) Within regular expression character classes ([]) the syntax
511 beginning with "[=" and ending with "=]" is reserved for future extensions.
512 If you need to represent those character sequences inside a regular
513 expression character class, just quote the square brackets with the
514 backslash: "\[=" and "=\]".
516 =item %s: Eval-group in insecure regular expression
518 (F) Perl detected tainted data when trying to compile a regular expression
519 that contains the C<(?{ ... })> zero-width assertion, which is unsafe.
520 See L<perlre/(?{ code })>, and L<perlsec>.
522 =item %s: Eval-group not allowed, use re 'eval'
524 (F) A regular expression contained the C<(?{ ... })> zero-width assertion,
525 but that construct is only allowed when the C<use re 'eval'> pragma is
526 in effect. See L<perlre/(?{ code })>.
528 =item %s: Eval-group not allowed at run time
530 (F) Perl tried to compile a regular expression containing the C<(?{ ... })>
531 zero-width assertion at run time, as it would when the pattern contains
532 interpolated values. Since that is a security risk, it is not allowed.
533 If you insist, you may still do this by explicitly building the pattern
534 from an interpolated string at run time and using that in an eval().
535 See L<perlre/(?{ code })>.
537 =item Explicit blessing to '' (assuming package main)
539 (W) You are blessing a reference to a zero length string. This has
540 the effect of blessing the reference into the package main. This is
541 usually not what you want. Consider providing a default target
542 package, e.g. bless($ref, $p or 'MyPackage');
544 =item Illegal hex digit ignored
546 (W) You may have tried to use a character other than 0 - 9 or A - F in a
547 hexadecimal number. Interpretation of the hexadecimal number stopped
548 before the illegal character.
550 =item No such array field
552 (F) You tried to access an array as a hash, but the field name used is
553 not defined. The hash at index 0 should map all valid field names to
554 array indices for that to work.
556 =item No such field "%s" in variable %s of type %s
558 (F) You tried to access a field of a typed variable where the type
559 does not know about the field name. The field names are looked up in
560 the %FIELDS hash in the type package at compile time. The %FIELDS hash
561 is usually set up with the 'fields' pragma.
563 =item Out of memory during ridiculously large request
565 (F) You can't allocate more than 2^31+"small amount" bytes. This error
566 is most likely to be caused by a typo in the Perl program. e.g., C<$arr[time]>
567 instead of C<$arr[$time]>.
569 =item Range iterator outside integer range
571 (F) One (or both) of the numeric arguments to the range operator ".."
572 are outside the range which can be represented by integers internally.
573 One possible workaround is to force Perl to use magical string
574 increment by prepending "0" to your numbers.
576 =item Recursive inheritance detected while looking for method '%s' in package '%s'
578 (F) More than 100 levels of inheritance were encountered while invoking a
579 method. Probably indicates an unintended loop in your inheritance hierarchy.
581 =item Reference found where even-sized list expected
583 (W) You gave a single reference where Perl was expecting a list with
584 an even number of elements (for assignment to a hash). This
585 usually means that you used the anon hash constructor when you meant
586 to use parens. In any case, a hash requires key/value B<pairs>.
588 %hash = { one => 1, two => 2, }; # WRONG
589 %hash = [ qw/ an anon array / ]; # WRONG
590 %hash = ( one => 1, two => 2, ); # right
591 %hash = qw( one 1 two 2 ); # also fine
593 =item Undefined value assigned to typeglob
595 (W) An undefined value was assigned to a typeglob, a la C<*foo = undef>.
596 This does nothing. It's possible that you really mean C<undef *foo>.
598 =item Use of reserved word "%s" is deprecated
600 (D) The indicated bareword is a reserved word. Future versions of perl
601 may use it as a keyword, so you're better off either explicitly quoting
602 the word in a manner appropriate for its context of use, or using a
603 different name altogether. The warning can be suppressed for subroutine
604 names by either adding a C<&> prefix, or using a package qualifier,
605 e.g. C<&our()>, or C<Foo::our()>.
607 =item perl: warning: Setting locale failed.
609 (S) The whole warning message will look something like:
611 perl: warning: Setting locale failed.
612 perl: warning: Please check that your locale settings:
615 are supported and installed on your system.
616 perl: warning: Falling back to the standard locale ("C").
618 Exactly what were the failed locale settings varies. In the above the
619 settings were that the LC_ALL was "En_US" and the LANG had no value.
620 This error means that Perl detected that you and/or your system
621 administrator have set up the so-called variable system but Perl could
622 not use those settings. This was not dead serious, fortunately: there
623 is a "default locale" called "C" that Perl can and will use, the
624 script will be run. Before you really fix the problem, however, you
625 will get the same error message each time you run Perl. How to really
626 fix the problem can be found in L<perllocale> section B<LOCALE PROBLEMS>.
631 =head1 Obsolete Diagnostics
637 (F) The mktemp() routine failed for some reason while trying to process
638 a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
640 =item Can't write to temp file for B<-e>: %s
642 (F) The write routine failed for some reason while trying to process
643 a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
645 =item Cannot open temporary file
647 (F) The create routine failed for some reason while trying to process
648 a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
655 If you find what you think is a bug, you might check the headers of
656 recently posted articles in the comp.lang.perl.misc newsgroup.
657 There may also be information at http://www.perl.com/perl/, the Perl
660 If you believe you have an unreported bug, please run the B<perlbug>
661 program included with your release. Make sure you trim your bug down
662 to a tiny but sufficient test case. Your bug report, along with the
663 output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
664 analysed by the Perl porting team.
668 The F<Changes> file for exhaustive details on what changed.
670 The F<INSTALL> file for how to build Perl.
672 The F<README> file for general stuff.
674 The F<Artistic> and F<Copying> files for copyright information.