3 perldelta - what is new for perl v5.9.5
7 This document describes differences between the 5.9.4 and the 5.9.5
8 development releases. See L<perl590delta>, L<perl591delta>,
9 L<perl592delta>, L<perl593delta> and L<perl594delta> for the differences
10 between 5.8.0 and 5.9.4.
12 =head1 Incompatible Changes
14 =head2 Tainting and printf
16 When perl is run under taint mode, C<printf()> and C<sprintf()> will now
17 reject any tainted format argument. (Rafael Garcia-Suarez)
19 =head2 undef and signal handlers
21 Undefining or deleting a signal handler via C<undef $SIG{FOO}> is now
22 equivalent to setting it to C<'DEFAULT'>. (Rafael)
24 =head2 strictures and array/hash dereferencing in defined()
26 C<defined @$foo> and C<defined %$bar> are now subject to C<strict 'refs'>
27 (that is, C<$foo> and C<$bar> shall be proper references there.)
30 (However, C<defined(@foo)> and C<defined(%bar)> are discouraged constructs
33 =head2 C<(?p{})> has been removed
35 The regular expression construct C<(?p{})>, which was deprecated in perl
36 5.8, has been removed. Use C<(??{})> instead. (Rafael)
38 =head2 Removal of the bytecode compiler and of perlcc
40 C<perlcc>, the byteloader and the supporting modules (B::C, B::CC,
41 B::Bytecode, etc.) are no longer distributed with the perl sources. Those
42 experimental tools have never worked reliably, and, due to the lack of
43 volunteers to keep them in line with the perl interpreter developments, it
44 was decided to remove them instead of shipping a broken version of those.
45 The last version of those modules can be found with perl 5.9.4.
47 However the B compiler framework stays supported in the perl core, as with
48 the more useful modules it has permitted (among others, B::Deparse and
51 =head2 Removal of the JPL
53 The JPL (Java-Perl Linguo) has been removed from the perl sources tarball.
55 =head2 Recursive inheritance detected earlier
57 Perl will now immediately throw an exception if you modify any package's
58 C<@ISA> in such a way that it would cause recursive inheritance.
60 Previously, the exception would not occur until Perl attempted to make
61 use of the recursive inheritance while resolving a method or doing a
62 C<$foo-E<gt>isa($bar)> lookup.
64 =head1 Core Enhancements
66 =head2 Regular expressions
70 =item Recursive Patterns
72 It is now possible to write recursive patterns without using the C<(??{})>
73 construct. This new way is more efficient, and in many cases easier to
76 Each capturing parenthesis can now be treated as an independent pattern
77 that can be entered by using the C<(?PARNO)> syntax (C<PARNO> standing for
78 "parenthesis number"). For example, the following pattern will match
79 nested balanced angle brackets:
83 ( # start capture buffer 1
84 < # match an opening angle bracket
86 (?> # don't backtrack over the inside of this group
87 [^<>]+ # one or more non angle brackets
88 ) # end non backtracking group
90 (?1) # recurse to bracket 1 and try it again
92 > # match a closing angle bracket
93 ) # end capture buffer one
97 Note, users experienced with PCRE will find that the Perl implementation
98 of this feature differs from the PCRE one in that it is possible to
99 backtrack into a recursed pattern, whereas in PCRE the recursion is
100 atomic or "possessive" in nature. (Yves Orton)
102 =item Named Capture Buffers
104 It is now possible to name capturing parenthesis in a pattern and refer to
105 the captured contents by name. The naming syntax is C<< (?<NAME>....) >>.
106 It's possible to backreference to a named buffer with the C<< \k<NAME> >>
107 syntax. In code, the new magical hashes C<%+> and C<%-> can be used to
108 access the contents of the capture buffers.
110 Thus, to replace all doubled chars, one could write
112 s/(?<letter>.)\k<letter>/$+{letter}/g
114 Only buffers with defined contents will be "visible" in the C<%+> hash, so
115 it's possible to do something like
117 foreach my $name (keys %+) {
118 print "content of buffer '$name' is $+{$name}\n";
121 The C<%-> hash is a bit more complete, since it will contain array refs
122 holding values from all capture buffers similarly named, if there should
125 C<%+> and C<%-> are implemented as tied hashes through the new module
126 C<Tie::Hash::NamedCapture>.
128 Users exposed to the .NET regex engine will find that the perl
129 implementation differs in that the numerical ordering of the buffers
130 is sequential, and not "unnamed first, then named". Thus in the pattern
132 /(A)(?<B>B)(C)(?<D>D)/
134 $1 will be 'A', $2 will be 'B', $3 will be 'C' and $4 will be 'D' and not
135 $1 is 'A', $2 is 'C' and $3 is 'B' and $4 is 'D' that a .NET programmer
136 would expect. This is considered a feature. :-) (Yves Orton)
138 =item Possessive Quantifiers
140 Perl now supports the "possessive quantifier" syntax of the "atomic match"
141 pattern. Basically a possessive quantifier matches as much as it can and never
142 gives any back. Thus it can be used to control backtracking. The syntax is
143 similar to non-greedy matching, except instead of using a '?' as the modifier
144 the '+' is used. Thus C<?+>, C<*+>, C<++>, C<{min,max}+> are now legal
145 quantifiers. (Yves Orton)
147 =item Backtracking control verbs
149 The regex engine now supports a number of special-purpose backtrack
150 control verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)
151 and (*ACCEPT). See L<perlre> for their descriptions. (Yves Orton)
153 =item Relative backreferences
155 A new syntax C<\g{N}> or C<\gN> where "N" is a decimal integer allows a
156 safer form of back-reference notation as well as allowing relative
157 backreferences. This should make it easier to generate and embed patterns
158 that contain backreferences. See L<perlre/"Capture buffers">. (Yves Orton)
162 The functionality of Jeff Pinyan's module Regexp::Keep has been added to
163 the core. You can now use in regular expressions the special escape C<\K>
164 as a way to do something like floating length positive lookbehind. It is
165 also useful in substitutions like:
169 that can now be converted to
173 which is much more efficient. (Yves Orton)
177 =head2 The C<_> prototype
179 A new prototype character has been added. C<_> is equivalent to C<$> (it
180 denotes a scalar), but defaults to C<$_> if the corresponding argument
181 isn't supplied. Due to the optional nature of the argument, you can only
182 use it at the end of a prototype, or before a semicolon.
184 This has a small incompatible consequence: the prototype() function has
185 been adjusted to return C<_> for some built-ins in appropriate cases (for
186 example, C<prototype('CORE::rmdir')>). (Rafael)
188 =head2 UNITCHECK blocks
190 C<UNITCHECK>, a new special code block has been introduced, in addition to
191 C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
193 C<CHECK> and C<INIT> blocks, while useful for some specialized purposes,
194 are always executed at the transition between the compilation and the
195 execution of the main program, and thus are useless whenever code is
196 loaded at runtime. On the other hand, C<UNITCHECK> blocks are executed
197 just after the unit which defined them has been compiled. See L<perlmod>
198 for more information. (Alex Gough)
200 =head2 readpipe() is now overridable
202 The built-in function readpipe() is now overridable. Overriding it permits
203 also to override its operator counterpart, C<qx//> (a.k.a. C<``>).
204 Moreover, it now defaults to C<$_> if no argument is provided. (Rafael)
206 =head2 default argument for readline()
208 readline() now defaults to C<*ARGV> if no argument is provided. (Rafael)
212 The copy of the Unicode Character Database included in Perl 5.9 has
213 been updated to version 5.0.0.
217 The smart match operator (C<~~>) is now available by default (you don't
218 need to enable it with C<use feature> any longer). (Michael G Schwern)
220 =head2 Implicit loading of C<feature>
222 The C<feature> pragma is now implicitly loaded when you require a minimal
223 perl version (with the C<use VERSION> construct) greater than, or equal
226 =head1 Modules and Pragmas
228 =head2 New Pragma, C<mro>
230 A new pragma, C<mro> (for Method Resolution Order) has been added. It
231 permits to switch, on a per-class basis, the algorithm that perl uses to
232 find inherited methods in case of a mutiple inheritance hierachy. The
233 default MRO hasn't changed (DFS, for Depth First Search). Another MRO is
234 available: the C3 algorithm. See L<mro> for more information.
237 =head2 New Core Modules
243 C<Locale::Maketext::Simple>, needed by CPANPLUS, is a simple wrapper around
244 C<Locale::Maketext::Lexicon>. Note that C<Locale::Maketext::Lexicon> isn't
245 included in the perl core; the behaviour of C<Locale::Maketext::Simple>
246 gracefully degrades when the later isn't present.
250 C<Params::Check> implements a generic input parsing/checking mechanism. It
255 C<Term::UI> simplifies the task to ask questions at a terminal prompt.
259 C<Object::Accessor> provides an interface to create per-object accessors.
263 C<Module::Pluggable> is a simple framework to create modules that accept
264 pluggable sub-modules.
268 C<Module::Load::Conditional> provides simple ways to query and possibly
269 load installed modules.
273 C<Time::Piece> provides an object oriented interface to time functions,
274 overriding the built-ins localtime() and gmtime().
278 C<IPC::Cmd> helps to find and run external commands, possibly
283 C<File::Fetch> provide a simple generic file fetching mechanism.
287 C<Archive::Extract> is a generic archive extraction mechanism
288 for F<.tar> (plain, gziped or bzipped) or F<.zip> files.
292 C<CPANPLUS> provides an API and a command-line tool to access the CPAN
297 =head2 Module changes
303 The C<base> pragma now warns if a class tries to inherit from itself.
306 =item C<strict> and C<warnings>
308 C<strict> and C<warnings> will now complain loudly if they are loaded via
309 incorrect casing (as in C<use Strict;>). (Johan Vromans)
313 The C<warnings> pragma doesn't load C<Carp> anymore. That means that code
314 that used C<Carp> routines without having loaded it at compile time might
315 need to be adjusted; typically, the following (faulty) code won't work
316 anymore, and will require parentheses to be added after the function name:
320 Carp::confess "argh";
324 C<less> now does something useful (or at least it tries to). In fact, it
325 has been turned into a lexical pragma. So, in your modules, you can now
326 test whether your users have requested to use less CPU, or less memory,
327 less magic, or maybe even less fat. See L<less> for more. (Joshua ben
330 =item C<Attribute::Handlers>
332 C<Attribute::Handlers> can now report the caller's file and line number.
337 C<B::Lint> is now based on C<Module::Pluggable>, and so can be extended
338 with plugins. (Joshua ben Jore)
342 It's now possible to access the lexical pragma hints (C<%^H>) by using the
343 method B::COP::hints_hash(). It returns a C<B::RHE> object, which in turn
344 can be used to get a hash reference via the method B::RHE::HASH(). (Joshua
347 =for p5p XXX document this in B.pm too
351 As the old 5005thread threading model has been removed, in favor of the
352 ithreads scheme, the C<Thread> module is now a compatibility wrapper, to
353 be used in old code only.
357 =head1 Utility Changes
361 C<cpanp>, the CPANPLUS shell, has been added. (C<cpanp-run-perl>, an
362 helper for CPANPLUS operation, has been added too, but isn't intended for
367 C<cpan2dist> is a new utility, that comes with CPANPLUS. It's a tool to
368 create distributions (or packages) from CPAN modules.
372 The output of C<pod2html> has been enhanced to be more customizable via
373 CSS. Some formatting problems were also corrected. (Jari Aalto)
377 =head2 New manpage, perlunifaq
379 A new manual page, L<perlunifaq> (the Perl Unicode FAQ), has been added
382 =head1 Performance Enhancements
384 =head1 Installation and Configuration Improvements
386 =head2 C++ compatibility
388 Efforts have been made to make perl and the core XS modules compilable
389 with various C++ compilers (although the situation is not perfect with
390 some of the compilers on some of the platforms tested.)
394 Perl now can be compiled with Microsoft Visual C++ 2005.
396 =head2 Static build on Win32
398 It's now possible to build a C<perl-static.exe> that doesn't depend
399 on C<perl59.dll> on Win32. See the Win32 makefiles for details.
402 =head2 C<d_pseudofork>
404 A new configuration variable, available as C<$Config{d_pseudofork}> in
405 the L<Config> module, has been added, to distinguish real fork() support
406 from fake pseudofork used on Windows platforms.
410 Perl has been reported to work on MidnightBSD.
412 =head1 Selected Bug Fixes
414 PerlIO::scalar will now prevent writing to read-only scalars. Moreover,
415 seek() is now supported with PerlIO::scalar-based filehandles, the
416 underlying string being zero-filled as needed. (Rafael, Jarkko Hietaniemi)
418 study() never worked for UTF-8 strings, but could lead to false results.
419 It's now a no-op on UTF-8 data. (Yves Orton)
421 The signals SIGILL, SIGBUS and SIGSEGV are now always delivered in an
422 "unsafe" manner (contrary to other signals, that are deferred until the
423 perl interpreter reaches a reasonably stable state; see
424 L<perlipc/"Deferred Signals (Safe Signals)">). (Rafael)
426 When a module or a file is loaded through an @INC-hook, and when this hook
427 has set a filename entry in %INC, __FILE__ is now set for this module
428 accordingly to the contents of that %INC entry. (Rafael)
430 The C<-w> and C<-t> switches can now be used together without messing
431 up what categories of warnings are activated or not. (Rafael)
433 Duping a filehandle which has the C<:utf8> PerlIO layer set will now
434 properly carry that layer on the duped filehandle. (Rafael)
436 =head1 New or Changed Diagnostics
440 Two deprecation warnings have been added: (Rafael)
442 Opening dirhandle %s also as a file
443 Opening filehandle %s also as a directory
445 =head1 Changed Internals
447 The anonymous hash and array constructors now take 1 op in the optree
448 instead of 3, now that pp_anonhash and pp_anonlist return a reference to
449 an hash/array when the op is flagged with OPf_SPECIAL (Nicholas Clark).
451 =for p5p XXX have we some docs on how to create regexp engine plugins, since that's now possible ? (perlreguts)
453 =for p5p XXX new BIND SV type, #29544, #29642
455 =head1 Known Problems
457 =head2 Platform Specific Problems
459 =head1 Reporting Bugs
461 If you find what you think is a bug, you might check the articles
462 recently posted to the comp.lang.perl.misc newsgroup and the perl
463 bug database at http://rt.perl.org/rt3/ . There may also be
464 information at http://www.perl.org/ , the Perl Home Page.
466 If you believe you have an unreported bug, please run the B<perlbug>
467 program included with your release. Be sure to trim your bug down
468 to a tiny but sufficient test case. Your bug report, along with the
469 output of C<perl -V>, will be sent off to perlbug@perl.org to be
470 analysed by the Perl porting team.
474 The F<Changes> file for exhaustive details on what changed.
476 The F<INSTALL> file for how to build Perl.
478 The F<README> file for general stuff.
480 The F<Artistic> and F<Copying> files for copyright information.