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 Removal of the bytecode compiler and of perlcc
35 C<perlcc>, the byteloader and the supporting modules (B::C, B::CC,
36 B::Bytecode, etc.) are no longer distributed with the perl sources. Those
37 experimental tools have never worked reliably, and, due to the lack of
38 volunteers to keep them in line with the perl interpreter developments, it
39 was decided to remove them instead of shipping a broken version of those.
40 The last version of those modules can be found with perl 5.9.4.
42 However the B compiler framework stays supported in the perl core, as with
43 the more useful modules it has permitted (among others, B::Deparse and
46 =head2 Removal of the JPL
48 The JPL (Java-Perl Linguo) has been removed from the perl sources tarball.
50 =head1 Core Enhancements
52 =head2 Regular expressions
56 =item Recursive Patterns
58 It is now possible to write recursive patterns without using the C<(??{})>
59 construct. This new way is more efficient, and in many cases easier to
62 Each capturing parenthesis can now be treated as an independent pattern
63 that can be entered by using the C<(?PARNO)> syntax (C<PARNO> standing for
64 "parenthesis number"). For example, the following pattern will match
65 nested balanced angle brackets:
69 ( # start capture buffer 1
70 < # match an opening angle bracket
72 (?> # don't backtrack over the inside of this group
73 [^<>]+ # one or more non angle brackets
74 ) # end non backtracking group
76 (?1) # recurse to bracket 1 and try it again
78 > # match a closing angle bracket
79 ) # end capture buffer one
83 Note, users experienced with PCRE will find that the Perl implementation
84 of this feature differs from the PCRE one in that it is possible to
85 backtrack into a recursed pattern, whereas in PCRE the recursion is
86 atomic or "possessive" in nature. (Yves Orton)
88 =item Named Capture Buffers
90 It is now possible to name capturing parenthesis in a pattern and refer to
91 the captured contents by name. The naming syntax is C<< (?<NAME>....) >>.
92 It's possible to backreference to a named buffer with the C<< \k<NAME> >>
93 syntax. In code, the new magical hashes C<%+> and C<%-> can be used to
94 access the contents of the capture buffers.
96 Thus, to replace all doubled chars, one could write
98 s/(?<letter>.)\k<letter>/$+{letter}/g
100 Only buffers with defined contents will be "visible" in the C<%+> hash, so
101 it's possible to do something like
103 foreach my $name (keys %+) {
104 print "content of buffer '$name' is $+{$name}\n";
107 The C<%-> hash is a bit more complete, since it will contain array refs
108 holding values from all capture buffers similarly named, if there should
111 C<%+> and C<%-> are implemented as tied hashes through the new module
112 C<re::Tie::Hash::NamedCapture>.
114 Users exposed to the .NET regex engine will find that the perl
115 implementation differs in that the numerical ordering of the buffers
116 is sequential, and not "unnamed first, then named". Thus in the pattern
118 /(A)(?<B>B)(C)(?<D>D)/
120 $1 will be 'A', $2 will be 'B', $3 will be 'C' and $4 will be 'D' and not
121 $1 is 'A', $2 is 'C' and $3 is 'B' and $4 is 'D' that a .NET programmer
122 would expect. This is considered a feature. :-) (Yves Orton)
124 =item Possessive Quantifiers
126 Perl now supports the "possessive quantifier" syntax of the "atomic match"
127 pattern. Basically a possessive quantifier matches as much as it can and never
128 gives any back. Thus it can be used to control backtracking. The syntax is
129 similar to non-greedy matching, except instead of using a '?' as the modifier
130 the '+' is used. Thus C<?+>, C<*+>, C<++>, C<{min,max}+> are now legal
131 quantifiers. (Yves Orton)
133 =item Backtracking control verbs
135 The regex engine now supports a number of special-purpose backtrack
136 control verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)
137 and (*ACCEPT). See L<perlre> for their descriptions. (Yves Orton)
139 =item Relative backreferences
141 A new syntax C<\g{N}> or C<\gN> where "N" is a decimal integer allows a
142 safer form of back-reference notation as well as allowing relative
143 backreferences. This should make it easier to generate and embed patterns
144 that contain backreferences. See L<perlre/"Capture buffers">. (Yves Orton)
148 The functionality of Jeff Pinyan's module Regexp::Keep has been added to
149 the core. You can now use in regular expressions the special escape C<\K>
150 as a way to do something like floating length positive lookbehind. It is
151 also useful in substitutions like:
155 that can now be converted to
159 which is much more efficient. (Yves Orton)
163 =head2 The C<_> prototype
165 A new prototype character has been added. C<_> is equivalent to C<$> (it
166 denotes a scalar), but defaults to C<$_> if the corresponding argument
167 isn't supplied. Due to the optional nature of the argument, you can only
168 use it at the end of a prototype, or before a semicolon.
170 This has a small incompatible consequence: the prototype() function has
171 been adjusted to return C<_> for some built-ins in appropriate cases (for
172 example, C<prototype('CORE::rmdir')>). (Rafael)
174 =head2 UNITCHECK blocks
176 C<UNITCHECK>, a new special code block has been introduced, in addition to
177 C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
179 C<CHECK> and C<INIT> blocks, while useful for some specialized purposes,
180 are always executed at the transition between the compilation and the
181 execution of the main program, and thus are useless whenever code is
182 loaded at runtime. On the other hand, C<UNITCHECK> blocks are executed
183 just after the unit which defined them has been compiled. See L<perlmod>
184 for more information. (Alex Gough)
186 =head2 readpipe() is now overridable
188 The built-in function readpipe() is now overridable. Overriding it permits
189 also to override its operator counterpart, C<qx//> (a.k.a. C<``>). (Rafael)
193 The copy of the Unicode Character Database included in Perl 5.9 has
194 been updated to version 5.0.0.
198 The smart match operator (C<~~>) is now available by default (you don't
199 need to enable it with C<use feature> any longer). (Michael G Schwern)
201 =head1 Modules and Pragmas
203 =head2 New Core Modules
209 C<Locale::Maketext::Simple>, needed by CPANPLUS, is a simple wrapper around
210 C<Locale::Maketext::Lexicon>. Note that C<Locale::Maketext::Lexicon> isn't
211 included in the perl core; the behaviour of C<Locale::Maketext::Simple>
212 gracefully degrades when the later isn't present.
216 C<Params::Check> implements a generic input parsing/checking mechanism. It
221 C<Term::UI> simplifies the task to ask questions at a terminal prompt.
225 C<Object::Accessor> provides an interface to create per-object accessors.
229 C<Module::Pluggable> is a simple framework to create modules that accept
230 pluggable sub-modules.
234 C<Module::Load::Conditional> provides simple ways to query and possibly
235 load installed modules.
239 C<Time::Piece> provides an object oriented interface to time functions,
240 overriding the built-ins localtime() and gmtime().
244 C<IPC::Cmd> helps to find and run external commands, possibly
249 C<File::Fetch> provide a simple generic file fetching mechanism.
253 C<Archive::Extract> is a generic archive extraction mechanism
254 for F<.tar> (plain, gziped or bzipped) or F<.zip> files.
258 =head2 Module changes
264 The C<base> pragma now warns if a class tries to inherit from itself.
269 The C<warnings> pragma doesn't load C<Carp> anymore. That means that code
270 that used C<Carp> routines without having loaded it at compile time might
271 need to be adjusted; typically, the following (faulty) code won't work
272 anymore, and will require parentheses to be added after the function name:
276 Carp::confess "argh";
280 C<less> now does something useful (or at least it tries to). In fact, it
281 has been turned into a lexical pragma. So, in your modules, you can now
282 test whether your users have requested to use less CPU, or less memory,
283 less magic, or maybe even less fat. See L<less> for more. (Joshua ben
286 =item C<Attribute::Handlers>
288 C<Attribute::Handlers> can now report the caller's file and line number.
293 C<B::Lint> is now based on C<Module::Pluggable>, and so can be extended
294 with plugins. (Joshua ben Jore)
298 It's now possible to access the lexical pragma hints (C<%^H>) by using the
299 method B::COP::hints_hash(). It returns a C<B::RHE> object, which in turn
300 can be used to get a hash reference via the method B::RHE::HASH(). (Joshua
303 =for p5p XXX document this in B.pm too
307 =head1 Utility Changes
311 =head1 Performance Enhancements
313 =head1 Installation and Configuration Improvements
315 =head2 C++ compatibility
317 Efforts have been made to make perl and the core XS modules compilable
318 with various C++ compilers (although the situation is not perfect with
319 some of the compilers on some of the platforms tested.)
321 =head2 Static build on Win32
323 It's now possible to build a C<perl-static.exe> that doesn't depend
324 on C<perl59.dll> on Win32. See the Win32 makefiles for details.
329 Perl has been reported to work on MidnightBSD.
331 =head1 Selected Bug Fixes
333 PerlIO::scalar will now prevent writing to read-only scalars. Moreover,
334 seek() is now supported with PerlIO::scalar-based filehandles, the
335 underlying string being zero-filled as needed. (Rafael, Jarkko Hietaniemi)
337 study() never worked for UTF-8 strings, but could lead to false results.
338 It's now a no-op on UTF-8 data. (Yves Orton)
340 The signals SIGILL, SIGBUS and SIGSEGV are now always delivered in an
341 "unsafe" manner (contrary to other signals, that are deferred until the
342 perl interpreter reaches a reasonably stable state; see
343 L<perlipc/"Deferred Signals (Safe Signals)">). (Rafael)
345 When a module or a file is loaded through an @INC-hook, and when this hook
346 has set a filename entry in %INC, __FILE__ is now set for this module
347 accordingly to the contents of that %INC entry. (Rafael)
349 The C<-w> and C<-t> switches can now be used together without messing
350 up what categories of warnings are activated or not. (Rafael)
352 =head1 New or Changed Diagnostics
354 =head1 Changed Internals
356 The anonymous hash and array constructors now take 1 op in the optree
357 instead of 3, now that pp_anonhash and pp_anonlist return a reference to
358 an hash/array when the op is flagged with OPf_SPECIAL (Nicholas Clark).
360 =for p5p XXX have we some docs on how to create regexp engine plugins, since that's now possible ? (perlreguts)
362 =for p5p XXX new BIND SV type, #29544, #29642
364 =head1 Known Problems
366 =head2 Platform Specific Problems
368 =head1 Reporting Bugs
370 If you find what you think is a bug, you might check the articles
371 recently posted to the comp.lang.perl.misc newsgroup and the perl
372 bug database at http://rt.perl.org/rt3/ . There may also be
373 information at http://www.perl.org/ , the Perl Home Page.
375 If you believe you have an unreported bug, please run the B<perlbug>
376 program included with your release. Be sure to trim your bug down
377 to a tiny but sufficient test case. Your bug report, along with the
378 output of C<perl -V>, will be sent off to perlbug@perl.org to be
379 analysed by the Perl porting team.
383 The F<Changes> file for exhaustive details on what changed.
385 The F<INSTALL> file for how to build Perl.
387 The F<README> file for general stuff.
389 The F<Artistic> and F<Copying> files for copyright information.