5 perl593delta - what is new for perl v5.9.3
9 This document describes differences between the 5.9.2 and the 5.9.3
10 development releases. See L<perl590delta>, L<perl591delta> and
11 L<perl592delta> for the differences between 5.8.0 and 5.9.2.
13 =head1 Incompatible Changes
15 =head2 Parsing of C<-f _>
17 The identifier C<_> is now forced to be a bareword after a filetest
18 operator. This solves a number of misparsing issues when a global C<_>
19 subroutine is defined.
23 C<mkdir()> without arguments now defaults to C<$_>.
25 =head2 Magic goto and eval
27 The construct C<eval { goto &foo }> is now disallowed. (Note that the
28 similar construct, but with C<eval("")> instead, was already forbidden.)
30 =head2 C<$#> has been removed
32 The deprecated C<$#> variable (output format for numbers) has been
33 removed. A new warning, C<$# is no longer supported>, has been added.
37 The C<:unique> attribute has been made a no-op, since its current
38 implementation was fundamentally flawed and not threadsafe.
40 =head2 Scoping of the C<sort> pragma
42 The C<sort> pragma is now lexically scoped. Its effect used to be global.
44 =head1 Core Enhancements
46 =head2 The C<feature> pragma
48 The C<feature> pragma is used to enable new syntax that would break Perl's
49 backwards-compatibility with older releases of the language. It's a lexical
50 pragma, like C<strict> or C<warnings>.
52 Currently the following new features are available: C<switch> (adds a
53 switch statement), C<~~> (adds a Perl 6-like smart match operator), C<say>
54 (adds a C<say> built-in function), and C<err> (adds an C<err> keyword).
55 Those features are described below.
57 Note that C<err> low-precedence defined-or operator used to be enabled by
58 default (although as a weak keyword, meaning that any function would
59 override it). It's now only recognized when explicitly turned on (and is
60 then a regular keyword).
62 Those features, and the C<feature> pragma itself, have been contributed by
65 =head2 Switch and Smart Match operator
67 Perl 5 now has a switch statement. It's available when C<use feature
68 'switch'> is in effect. This feature introduces three new keywords,
69 C<given>, C<when>, and C<default>:
72 when (/^abc/) { $abc = 1; }
73 when (/^def/) { $def = 1; }
74 when (/^xyz/) { $xyz = 1; }
75 default { $nothing = 1; }
78 A more complete description of how Perl matches the switch variable
79 against the C<when> conditions is given in L<perlsyn/"Switch statements">.
81 This kind of match is called I<smart match>, and it's also possible to use
82 it outside of switch statements, via the new C<~~> operator (enabled via
83 the C<use feature '~~'> directive). See L<perlsyn/"Smart matching in
88 say() is a new built-in, only available when C<use feature 'say'> is in
89 effect, that is similar to print(), but that implicitly appends a newline
90 to the printed string. See L<perlfunc/say>.
92 =head2 C<CLONE_SKIP()>
94 Perl has now support for the C<CLONE_SKIP> special subroutine. Like
95 C<CLONE>, C<CLONE_SKIP> is called once per package; however, it is called
96 just before cloning starts, and in the context of the parent thread. If it
97 returns a true value, then no objects of that class will be cloned. See
98 L<perlmod> for details. (Contributed by Dave Mitchell.)
100 =head2 C<${^CHILD_ERROR_NATIVE}>
102 A new internal variable, C<${^CHILD_ERROR_NATIVE}>, gives the native
103 status returned by the last pipe close, backtick command, successful call
104 to wait() or waitpid(), or from the system() operator. See L<perlrun> for
105 details. (Contributed by Gisle Aas.)
109 The support for assertions, introduced in perl 5.9.0, has been improved.
110 The syntax for the C<-A> command-line switch has changed; it now accepts
111 an optional module name, defaulting to C<assertions::activate>. See
112 L<assertions> and L<perlrun>. (Contributed by Salvador Fandiño García.)
114 =head2 Unicode Character Database 4.1.0
116 The copy of the Unicode Character Database included in Perl 5.9 has
117 been updated to 4.1.0.
121 You can now use C<no> followed by a version number to specify that you
122 want to use a version of perl older than the specified one.
124 =head2 Recursive sort subs
126 You can now use recursive subroutines with sort(), thanks to Robin Houston.
128 =head2 Effect of pragmas in eval
130 The compile-time value of the C<%^H> hint variable can now propagate into
131 eval("")uated code. This makes it more useful to implement lexical
134 As a side-effect of this, the overloaded-ness of constants now propagates
137 =head2 New B<-E> command-line switch
139 B<-E> is equivalent to B<-e>, but it implicitly enables all
140 optional features (like C<use feature ":5.10">).
142 =head2 C<chdir>, C<chmod> and C<chown> on filehandles
144 C<chdir>, C<chmod> and C<chown> can now work on filehandles as well as
145 filenames, if the system supports respectively C<fchdir>, C<fchmod> and
146 C<fchown>, thanks to a patch provided by Gisle Aas.
150 C<$(> and C<$)> now return groups in the order where the OS returns them,
151 thanks to Gisle Aas. This wasn't previously the case.
153 =head1 Modules and Pragmata
155 =head2 New Core Modules
161 A new pragma, C<feature>, has been added; see above in L</"Core
166 C<assertions::compat>, also available on CPAN, allows the use of assertions on
167 perl versions prior to 5.9.0 (that is the first one to natively support
172 C<Math::BigInt::FastCalc> is an XS-enabled, and thus faster, version of
173 C<Math::BigInt::Calc>.
177 C<Compress::Zlib> is an interface to the zlib compression library. It
178 comes with a bundled version of zlib, so having a working zlib is not a
179 prerequisite to install it. It's used by C<Archive::Tar> (see below).
183 C<IO::Zlib> is an C<IO::>-style interface to C<Compress::Zlib>.
187 C<Archive::Tar> is a module to manipulate C<tar> archives.
191 C<Digest::SHA> is a module used to calculate many types of SHA digests,
192 has been included for SHA support in the CPAN module.
196 C<ExtUtils::CBuilder> and C<ExtUtils::ParseXS> have been added.
200 =head1 Utility Changes
204 C<ptar> is a pure perl implementation of C<tar>, that comes with
209 C<ptardiff> is a small script used to generate a diff between the contents
210 of a tar archive and a directory tree. Like C<ptar>, it comes with
215 This command-line utility, used to print or to check SHA digests, comes
216 with the new C<Digest::SHA> module.
218 =head2 C<h2xs> enhancements
220 C<h2xs> implements a new option C<--use-xsloader> to force use of
221 C<XSLoader> even in backwards compatible modules.
223 The handling of authors' names that had apostrophes has been fixed.
225 Any enums with negative values are now skipped.
227 =head2 C<perlivp> enhancements
229 C<perlivp> no longer checks for F<*.ph> files by default. Use the new C<-a>
230 option to run I<all> tests.
236 The L<perlglossary> manpage is a glossary of terms used in the Perl
237 documentation, technical and otherwise, kindly provided by O'Reilly Media,
240 L<perltodo> now lists a rough roadmap to Perl 5.10.
242 =head1 Performance Enhancements
244 =head2 XS-assisted SWASHGET
246 Some pure-perl code that perl was using to retrieve Unicode properties and
247 transliteration mappings has been reimplemented in XS.
249 =head2 Constant subroutines
251 The interpreter internals now support a far more memory efficient form of
252 inlineable constants. Storing a reference to a constant value in a symbol
253 table is equivalent to a full typeglob referencing a constant subroutine,
254 but using about 400 bytes less memory. This proxy constant subroutine is
255 automatically upgraded to a real typeglob with subroutine if necessary.
256 The approach taken is analogous to the existing space optimisation for
257 subroutine stub declarations, which are stored as plain scalars in place
258 of the full typeglob.
260 Several of the core modules have been converted to use this feature for
261 their system dependent constants - as a result C<use POSIX;> now takes about
264 =head2 C<PERL_DONT_CREATE_GVSV>
266 The new compilation flag C<PERL_DONT_CREATE_GVSV>, introduced as an option
267 in perl 5.8.8, is turned on by default in perl 5.9.3. It prevents perl
268 from creating an empty scalar with every new typeglob. See L<perl589delta>
271 =head2 Weak references are cheaper
273 Weak reference creation is now I<O(1)> rather than I<O(n)>, courtesy of
274 Nicholas Clark. Weak reference deletion remains I<O(n)>, but if deletion only
275 happens at program exit, it may be skipped completely.
277 =head2 sort() enhancements
279 Salvador Fandiño provided improvements to reduce the memory usage of C<sort>
280 and to speed up some cases.
282 =head1 Installation and Configuration Improvements
284 =head2 Compilation improvements
286 Parallel makes should work properly now, although there may still be problems
287 if C<make test> is instructed to run in parallel.
289 Building with Borland's compilers on Win32 should work more smoothly. In
290 particular Steve Hay has worked to side step many warnings emitted by their
291 compilers and at least one C compiler internal error.
293 Perl extensions on Windows now can be statically built into the Perl DLL,
294 thanks to a work by Vadim Konovalov.
296 =head2 New Or Improved Platforms
298 Perl is being ported to Symbian OS. See L<perlsymbian> for more
301 The VMS port has been improved. See L<perlvms>.
303 DynaLoader::dl_unload_file() now works on Windows.
305 Portability of Perl on various recent compilers on Windows has been
306 improved (Borland C++, Visual C++ 7.0).
310 C<Configure> will now detect C<clearenv> and C<unsetenv>, thanks to a
311 patch from Alan Burlison. It will also probe for C<futimes> (and use it
312 internally if available), and whether C<sprintf> correctly returns the
313 length of the formatted string.
315 =head2 Module auxiliary files
317 README files and changelogs for CPAN modules bundled with perl are no
320 =head1 Selected Bug Fixes
322 =head2 C<defined $$x>
324 C<use strict "refs"> was ignoring taking a hard reference in an argument
325 to defined(), as in :
329 if (defined $$x) {...}
331 This now correctly produces the run-time error C<Can't use string as a
332 SCALAR ref while "strict refs" in use>. (However, C<defined @$foo> and
333 C<defined %$foo> are still allowed. Those constructs are discouraged
336 =head2 Calling CORE::require()
338 CORE::require() and CORE::do() were always parsed as require() and do()
339 when they were overridden. This is now fixed.
341 =head2 Subscripts of slices
343 You can now use a non-arrowed form for chained subscripts after a list
346 ({foo => "bar"})[0]{foo}
348 This used to be a syntax error; a C<< -> >> was required.
350 =head2 Remove over-optimisation
352 Perl 5.9.2 introduced a change so that assignments of C<undef> to a
353 scalar, or of an empty list to an array or a hash, were optimised out. As
354 this could cause problems when C<goto> jumps were involved, this change
357 =head2 sprintf() fixes
359 Using the sprintf() function with some formats could lead to a buffer
360 overflow in some specific cases. This has been fixed, along with several
361 other bugs, notably in bounds checking.
363 In related fixes, it was possible for badly written code that did not follow
364 the documentation of C<Sys::Syslog> to have formatting vulnerabilities.
365 C<Sys::Syslog> has been changed to protect people from poor quality third
368 =head2 no warnings 'category' works correctly with -w
370 Previously when running with warnings enabled globally via C<-w>, selective
371 disabling of specific warning categories would actually turn off all warnings.
372 This is now fixed; now C<no warnings 'io';> will only turn off warnings in the
373 C<io> class. Previously it would erroneously turn off all warnings.
381 C<FindBin> now works better with directories where access rights are more
382 restrictive than usual.
386 Several memory leaks in ithreads were closed. Also, ithreads were made
387 less memory-intensive.
391 Trailing spaces are now trimmed from C<$!> and C<$^E>.
395 Operations that require perl to read a process's list of groups, such as reads
396 of C<$(> and C<$)>, now dynamically allocate memory rather than using a
397 fixed sized array. The fixed size array could cause C stack exhaustion on
398 systems configured to use large numbers of groups.
402 C<PerlIO::scalar> now works better with non-default C<$/> settings.
406 The C<x> repetition operator is now able to operate on C<qw//> lists. This
407 used to raise a syntax error.
411 The debugger now traces correctly execution in eval("")uated code that
412 contains #line directives.
416 The value of the C<open> pragma is no longer ignored for three-argument
421 Perl will now use the C library calls C<unsetenv> and C<clearenv> if present
422 to delete keys from C<%ENV> and delete C<%ENV> entirely, thanks to a patch
427 =head2 More Unicode Fixes
433 chr() on a negative value now gives C<\x{FFFD}>, the Unicode replacement
434 character, unless when the C<bytes> pragma is in effect, where the low
435 eight bytes of the value are used.
439 Some case insensitive matches between UTF-8 encoded data and 8 bit regexps,
440 and vice versa, could give malformed character warnings. These have been
441 fixed by Dave Mitchell and Yves Orton.
445 C<lcfirst> and C<ucfirst> could corrupt the string for certain cases where
446 the length UTF-8 encoding of the string in lower case, upper case or title
447 case differed. This was fixed by Nicholas Clark.
451 =head1 New or Changed Diagnostics
453 =head2 Attempt to set length of freed array
455 This is a new warning, produced in situations like the following one:
457 $r = do {my @a; \$#a};
460 =head2 Non-string passed as bitmask
462 This is a new warning, produced when number has been passed as a argument to
463 select(), instead of a bitmask.
465 # Wrong, will now warn
466 $rin = fileno(STDIN);
467 ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout);
471 vec($rin,fileno(STDIN),1) = 1;
472 ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout);
474 =head2 Search pattern not terminated or ternary operator parsed as search pattern
476 This syntax error indicates that the lexer couldn't find the final
477 delimiter of a C<?PATTERN?> construct. Mentioning the ternary operator in
478 this error message makes syntax diagnostic easier.
480 =head2 "%s" variable %s masks earlier declaration
482 This warning is now emitted in more consistent cases; in short, when one
483 of the declarations involved is a C<my> variable:
485 my $x; my $x; # warns
486 my $x; our $x; # warns
487 our $x; my $x; # warns
489 On the other hand, the following:
493 now gives a C<"our" variable %s redeclared> warning.
495 =head2 readdir()/closedir()/etc. attempted on invalid dirhandle
497 These new warnings are now emitted when a dirhandle is used but is
498 either closed or not really a dirhandle.
500 =head1 Changed Internals
502 In general, the source code of perl has been refactored, tied up, and
503 optimized in many places. Also, memory management and allocation has been
504 improved in a couple of points.
506 Andy Lester supplied many improvements to determine which function
507 parameters and local variables could actually be declared C<const> to the C
508 compiler. Steve Peters provided new C<*_set> macros and reworked the core to
509 use these rather than assigning to macros in LVALUE context.
511 Dave Mitchell improved the lexer debugging output under C<-DT>.
513 A new file, F<mathoms.c>, has been added. It contains functions that are
514 no longer used in the perl core, but that remain available for binary or
515 source compatibility reasons. However, those functions will not be
516 compiled in if you add C<-DNO_MATHOMS> in the compiler flags.
518 The C<AvFLAGS> macro has been removed.
520 The C<av_*()> functions, used to manipulate arrays, no longer accept null
523 =head2 B:: modules inheritance changed
525 The inheritance hierarchy of C<B::> modules has changed; C<B::NV> now
526 inherits from C<B::SV> (it used to inherit from C<B::IV>).
528 =head1 Reporting Bugs
530 If you find what you think is a bug, you might check the articles
531 recently posted to the comp.lang.perl.misc newsgroup and the perl
532 bug database at http://bugs.perl.org/ . There may also be
533 information at http://www.perl.org/ , the Perl Home Page.
535 If you believe you have an unreported bug, please run the B<perlbug>
536 program included with your release. Be sure to trim your bug down
537 to a tiny but sufficient test case. Your bug report, along with the
538 output of C<perl -V>, will be sent off to perlbug@perl.org to be
539 analysed by the Perl porting team.
543 The F<Changes> file for exhaustive details on what changed.
545 The F<INSTALL> file for how to build Perl.
547 The F<README> file for general stuff.
549 The F<Artistic> and F<Copying> files for copyright information.