This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Changes
[perl5.git] / pod / perl595delta.pod
CommitLineData
f6eae373
RGS
1=head1 NAME
2
3perldelta - what is new for perl v5.9.5
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.9.4 and the 5.9.5
8development releases. See L<perl590delta>, L<perl591delta>,
9L<perl592delta>, L<perl593delta> and L<perl594delta> for the differences
10between 5.8.0 and 5.9.4.
11
12=head1 Incompatible Changes
13
20ee07fb
RGS
14=head2 Tainting and printf
15
16When perl is run under taint mode, C<printf()> and C<sprintf()> will now
3f10c77a 17reject any tainted format argument. (Rafael Garcia-Suarez)
20ee07fb 18
54a37cc6
RGS
19=head2 undef and signal handlers
20
21Undefining or deleting a signal handler via C<undef $SIG{FOO}> is now
97f820fb
RGS
22equivalent to setting it to C<'DEFAULT'>. (Rafael)
23
24=head2 strictures and array/hash dereferencing in defined()
25
26C<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.)
28(Nicholas Clark)
29
30(However, C<defined(@foo)> and C<defined(%bar)> are discouraged constructs
31anyway.)
54a37cc6 32
74bb26f2
RGS
33=head2 C<(?p{})> has been removed
34
35The regular expression construct C<(?p{})>, which was deprecated in perl
365.8, has been removed. Use C<(??{})> instead. (Rafael)
37
73966613
RGS
38=head2 Removal of the bytecode compiler and of perlcc
39
40C<perlcc>, the byteloader and the supporting modules (B::C, B::CC,
41B::Bytecode, etc.) are no longer distributed with the perl sources. Those
42experimental tools have never worked reliably, and, due to the lack of
43volunteers to keep them in line with the perl interpreter developments, it
44was decided to remove them instead of shipping a broken version of those.
45The last version of those modules can be found with perl 5.9.4.
46
47However the B compiler framework stays supported in the perl core, as with
48the more useful modules it has permitted (among others, B::Deparse and
49B::Concise).
50
51=head2 Removal of the JPL
52
53The JPL (Java-Perl Linguo) has been removed from the perl sources tarball.
54
afa2ea4a
RGS
55=head2 Recursive inheritance detected earlier
56
57Perl will now immediately throw an exception if you modify any package's
58C<@ISA> in such a way that it would cause recursive inheritance.
59
60Previously, the exception would not occur until Perl attempted to make
61use of the recursive inheritance while resolving a method or doing a
62C<$foo-E<gt>isa($bar)> lookup.
63
f6eae373
RGS
64=head1 Core Enhancements
65
072f65b4
RGS
66=head2 Regular expressions
67
68=over 4
69
70=item Recursive Patterns
71
72It is now possible to write recursive patterns without using the C<(??{})>
73construct. This new way is more efficient, and in many cases easier to
74read.
75
76Each capturing parenthesis can now be treated as an independent pattern
77that can be entered by using the C<(?PARNO)> syntax (C<PARNO> standing for
78"parenthesis number"). For example, the following pattern will match
79nested balanced angle brackets:
80
81 /
82 ^ # start of line
83 ( # start capture buffer 1
84 < # match an opening angle bracket
85 (?: # match one of:
86 (?> # don't backtrack over the inside of this group
87 [^<>]+ # one or more non angle brackets
88 ) # end non backtracking group
89 | # ... or ...
90 (?1) # recurse to bracket 1 and try it again
91 )* # 0 or more times.
92 > # match a closing angle bracket
93 ) # end capture buffer one
94 $ # end of line
95 /x
96
97Note, users experienced with PCRE will find that the Perl implementation
98of this feature differs from the PCRE one in that it is possible to
99backtrack into a recursed pattern, whereas in PCRE the recursion is
73966613 100atomic or "possessive" in nature. (Yves Orton)
072f65b4
RGS
101
102=item Named Capture Buffers
103
104It is now possible to name capturing parenthesis in a pattern and refer to
105the captured contents by name. The naming syntax is C<< (?<NAME>....) >>.
106It's possible to backreference to a named buffer with the C<< \k<NAME> >>
97f820fb
RGS
107syntax. In code, the new magical hashes C<%+> and C<%-> can be used to
108access the contents of the capture buffers.
072f65b4
RGS
109
110Thus, to replace all doubled chars, one could write
111
112 s/(?<letter>.)\k<letter>/$+{letter}/g
113
97f820fb 114Only buffers with defined contents will be "visible" in the C<%+> hash, so
072f65b4
RGS
115it's possible to do something like
116
117 foreach my $name (keys %+) {
118 print "content of buffer '$name' is $+{$name}\n";
119 }
120
97f820fb
RGS
121The C<%-> hash is a bit more complete, since it will contain array refs
122holding values from all capture buffers similarly named, if there should
123be many of them.
124
125C<%+> and C<%-> are implemented as tied hashes through the new module
80305961 126C<Tie::Hash::NamedCapture>.
97f820fb 127
072f65b4
RGS
128Users exposed to the .NET regex engine will find that the perl
129implementation differs in that the numerical ordering of the buffers
130is sequential, and not "unnamed first, then named". Thus in the pattern
131
132 /(A)(?<B>B)(C)(?<D>D)/
133
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
73966613 136would expect. This is considered a feature. :-) (Yves Orton)
072f65b4 137
b9b4dddf
YO
138=item Possessive Quantifiers
139
ee9b8eae 140Perl now supports the "possessive quantifier" syntax of the "atomic match"
b9b4dddf 141pattern. Basically a possessive quantifier matches as much as it can and never
ee9b8eae 142gives any back. Thus it can be used to control backtracking. The syntax is
b9b4dddf
YO
143similar to non-greedy matching, except instead of using a '?' as the modifier
144the '+' is used. Thus C<?+>, C<*+>, C<++>, C<{min,max}+> are now legal
73966613 145quantifiers. (Yves Orton)
b9b4dddf 146
24b23f37
YO
147=item Backtracking control verbs
148
3f10c77a 149The regex engine now supports a number of special-purpose backtrack
5d458dd8 150control verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)
c74340f9
YO
151and (*ACCEPT). See L<perlre> for their descriptions. (Yves Orton)
152
153=item Relative backreferences
154
2bf803e2
YO
155A new syntax C<\g{N}> or C<\gN> where "N" is a decimal integer allows a
156safer form of back-reference notation as well as allowing relative
157backreferences. This should make it easier to generate and embed patterns
3f10c77a 158that contain backreferences. See L<perlre/"Capture buffers">. (Yves Orton)
24b23f37 159
97f820fb 160=item C<\K> escape
ee9b8eae
YO
161
162The functionality of Jeff Pinyan's module Regexp::Keep has been added to
163the core. You can now use in regular expressions the special escape C<\K>
164as a way to do something like floating length positive lookbehind. It is
165also useful in substitutions like:
166
167 s/(foo)bar/$1/g
168
169that can now be converted to
170
171 s/foo\Kbar//g
172
97f820fb 173which is much more efficient. (Yves Orton)
ee9b8eae 174
41b9272f
RGS
175=item Vertical and horizontal whitespace, and linebreak
176
177Regular expressions now recognize the C<\v> and C<\h> escapes, that match
178vertical and horizontal whitespace, respectively. C<\V> and C<\H>
179logically match their complements.
180
329d35d1 181C<\R> matches a generic linebreak, that is, vertical whitespace, plus
41b9272f
RGS
182the multi-character sequence C<"\x0D\x0A">.
183
75c442e4
NC
184=back
185
d5494b07
RGS
186=head2 The C<_> prototype
187
188A new prototype character has been added. C<_> is equivalent to C<$> (it
189denotes a scalar), but defaults to C<$_> if the corresponding argument
190isn't supplied. Due to the optional nature of the argument, you can only
191use it at the end of a prototype, or before a semicolon.
192
73966613
RGS
193This has a small incompatible consequence: the prototype() function has
194been adjusted to return C<_> for some built-ins in appropriate cases (for
97f820fb 195example, C<prototype('CORE::rmdir')>). (Rafael)
73966613 196
49f595a6
RGS
197=head2 UNITCHECK blocks
198
199C<UNITCHECK>, a new special code block has been introduced, in addition to
200C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
201
202C<CHECK> and C<INIT> blocks, while useful for some specialized purposes,
203are always executed at the transition between the compilation and the
204execution of the main program, and thus are useless whenever code is
205loaded at runtime. On the other hand, C<UNITCHECK> blocks are executed
206just after the unit which defined them has been compiled. See L<perlmod>
207for more information. (Alex Gough)
208
5a093634
RGS
209=head2 readpipe() is now overridable
210
211The built-in function readpipe() is now overridable. Overriding it permits
74bb26f2
RGS
212also to override its operator counterpart, C<qx//> (a.k.a. C<``>).
213Moreover, it now defaults to C<$_> if no argument is provided. (Rafael)
214
215=head2 default argument for readline()
216
217readline() now defaults to C<*ARGV> if no argument is provided. (Rafael)
5a093634 218
73966613
RGS
219=head2 UCD 5.0.0
220
221The copy of the Unicode Character Database included in Perl 5.9 has
222been updated to version 5.0.0.
223
97f820fb
RGS
224=head2 Smart match
225
226The smart match operator (C<~~>) is now available by default (you don't
227need to enable it with C<use feature> any longer). (Michael G Schwern)
228
74bb26f2
RGS
229=head2 Implicit loading of C<feature>
230
231The C<feature> pragma is now implicitly loaded when you require a minimal
232perl version (with the C<use VERSION> construct) greater than, or equal
233to, 5.9.5.
234
f6eae373
RGS
235=head1 Modules and Pragmas
236
74bb26f2
RGS
237=head2 New Pragma, C<mro>
238
239A new pragma, C<mro> (for Method Resolution Order) has been added. It
240permits to switch, on a per-class basis, the algorithm that perl uses to
241find inherited methods in case of a mutiple inheritance hierachy. The
242default MRO hasn't changed (DFS, for Depth First Search). Another MRO is
243available: the C3 algorithm. See L<mro> for more information.
244(Brandon Black)
245
91ddf7c8
RGS
246Note that, due to changes in the implentation of class hierarchy search,
247code that used to undef the C<*ISA> glob will most probably break. Anyway,
248undef'ing C<*ISA> had the side-effect of removing the magic on the @ISA
249array and should not have been done in the first place.
250
3284ac36
RGS
251=head2 bignum, bigint, bigrat
252
253The three numeric pragmas C<bignum>, C<bigint> and C<bigrat> are now
254lexically scoped. (Tels)
255
f6eae373
RGS
256=head2 New Core Modules
257
73966613
RGS
258=over 4
259
260=item *
261
262C<Locale::Maketext::Simple>, needed by CPANPLUS, is a simple wrapper around
263C<Locale::Maketext::Lexicon>. Note that C<Locale::Maketext::Lexicon> isn't
264included in the perl core; the behaviour of C<Locale::Maketext::Simple>
265gracefully degrades when the later isn't present.
266
267=item *
268
269C<Params::Check> implements a generic input parsing/checking mechanism. It
270is used by CPANPLUS.
271
5a093634
RGS
272=item *
273
274C<Term::UI> simplifies the task to ask questions at a terminal prompt.
275
276=item *
277
278C<Object::Accessor> provides an interface to create per-object accessors.
279
97f820fb
RGS
280=item *
281
282C<Module::Pluggable> is a simple framework to create modules that accept
283pluggable sub-modules.
284
285=item *
286
287C<Module::Load::Conditional> provides simple ways to query and possibly
288load installed modules.
289
290=item *
291
292C<Time::Piece> provides an object oriented interface to time functions,
293overriding the built-ins localtime() and gmtime().
294
295=item *
296
297C<IPC::Cmd> helps to find and run external commands, possibly
298interactively.
299
300=item *
301
302C<File::Fetch> provide a simple generic file fetching mechanism.
303
304=item *
305
306C<Archive::Extract> is a generic archive extraction mechanism
307for F<.tar> (plain, gziped or bzipped) or F<.zip> files.
308
74bb26f2
RGS
309=item *
310
311C<CPANPLUS> provides an API and a command-line tool to access the CPAN
312mirrors.
313
73966613
RGS
314=back
315
d5494b07
RGS
316=head2 Module changes
317
318=over 4
319
ddf4dafe
RGS
320=item C<assertions>
321
322The C<assertions> pragma, its submodules C<assertions::activate> and
323C<assertions::compat> and the B<-A> command-line switch have been removed.
324The interface was not judged mature enough for inclusion in a stable
325release.
326
d5494b07
RGS
327=item C<base>
328
329The C<base> pragma now warns if a class tries to inherit from itself.
97f820fb 330(Curtis "Ovid" Poe)
d5494b07 331
74bb26f2
RGS
332=item C<strict> and C<warnings>
333
334C<strict> and C<warnings> will now complain loudly if they are loaded via
335incorrect casing (as in C<use Strict;>). (Johan Vromans)
336
18857c0b
RGS
337=item C<warnings>
338
339The C<warnings> pragma doesn't load C<Carp> anymore. That means that code
340that used C<Carp> routines without having loaded it at compile time might
341need to be adjusted; typically, the following (faulty) code won't work
342anymore, and will require parentheses to be added after the function name:
343
344 use warnings;
345 require Carp;
346 Carp::confess "argh";
347
97f820fb
RGS
348=item C<less>
349
350C<less> now does something useful (or at least it tries to). In fact, it
351has been turned into a lexical pragma. So, in your modules, you can now
352test whether your users have requested to use less CPU, or less memory,
353less magic, or maybe even less fat. See L<less> for more. (Joshua ben
354Jore)
355
3f10c77a
RGS
356=item C<Attribute::Handlers>
357
358C<Attribute::Handlers> can now report the caller's file and line number.
359(David Feldman)
360
97f820fb
RGS
361=item C<B::Lint>
362
363C<B::Lint> is now based on C<Module::Pluggable>, and so can be extended
364with plugins. (Joshua ben Jore)
365
366=item C<B>
367
368It's now possible to access the lexical pragma hints (C<%^H>) by using the
369method B::COP::hints_hash(). It returns a C<B::RHE> object, which in turn
370can be used to get a hash reference via the method B::RHE::HASH(). (Joshua
371ben Jore)
372
373=for p5p XXX document this in B.pm too
374
ab4e6221
RGS
375=item C<Thread>
376
377As the old 5005thread threading model has been removed, in favor of the
378ithreads scheme, the C<Thread> module is now a compatibility wrapper, to
379be used in old code only.
380
d5494b07
RGS
381=back
382
f6eae373
RGS
383=head1 Utility Changes
384
74bb26f2
RGS
385=head2 C<cpanp>
386
387C<cpanp>, the CPANPLUS shell, has been added. (C<cpanp-run-perl>, an
388helper for CPANPLUS operation, has been added too, but isn't intended for
389direct use).
390
8a499140
RGS
391=head2 C<cpan2dist>
392
393C<cpan2dist> is a new utility, that comes with CPANPLUS. It's a tool to
394create distributions (or packages) from CPAN modules.
395
74bb26f2
RGS
396=head2 C<pod2html>
397
398The output of C<pod2html> has been enhanced to be more customizable via
399CSS. Some formatting problems were also corrected. (Jari Aalto)
400
f6eae373
RGS
401=head1 Documentation
402
74bb26f2
RGS
403=head2 New manpage, perlunifaq
404
405A new manual page, L<perlunifaq> (the Perl Unicode FAQ), has been added
406(Juerd Waalboer).
407
f6eae373
RGS
408=head1 Performance Enhancements
409
410=head1 Installation and Configuration Improvements
411
73966613
RGS
412=head2 C++ compatibility
413
414Efforts have been made to make perl and the core XS modules compilable
415with various C++ compilers (although the situation is not perfect with
416some of the compilers on some of the platforms tested.)
417
ab4e6221
RGS
418=head2 Visual C++
419
420Perl now can be compiled with Microsoft Visual C++ 2005.
421
3f10c77a
RGS
422=head2 Static build on Win32
423
424It's now possible to build a C<perl-static.exe> that doesn't depend
425on C<perl59.dll> on Win32. See the Win32 makefiles for details.
e3c82801 426(Vadim Konovalov)
3f10c77a 427
ab4e6221
RGS
428=head2 C<d_pseudofork>
429
430A new configuration variable, available as C<$Config{d_pseudofork}> in
431the L<Config> module, has been added, to distinguish real fork() support
432from fake pseudofork used on Windows platforms.
433
73966613
RGS
434=head2 Ports
435
436Perl has been reported to work on MidnightBSD.
437
f6eae373
RGS
438=head1 Selected Bug Fixes
439
49f595a6
RGS
440PerlIO::scalar will now prevent writing to read-only scalars. Moreover,
441seek() is now supported with PerlIO::scalar-based filehandles, the
97f820fb 442underlying string being zero-filled as needed. (Rafael, Jarkko Hietaniemi)
73966613
RGS
443
444study() never worked for UTF-8 strings, but could lead to false results.
445It's now a no-op on UTF-8 data. (Yves Orton)
446
49f595a6
RGS
447The signals SIGILL, SIGBUS and SIGSEGV are now always delivered in an
448"unsafe" manner (contrary to other signals, that are deferred until the
449perl interpreter reaches a reasonably stable state; see
97f820fb 450L<perlipc/"Deferred Signals (Safe Signals)">). (Rafael)
49f595a6 451
5a093634
RGS
452When a module or a file is loaded through an @INC-hook, and when this hook
453has set a filename entry in %INC, __FILE__ is now set for this module
97f820fb
RGS
454accordingly to the contents of that %INC entry. (Rafael)
455
456The C<-w> and C<-t> switches can now be used together without messing
457up what categories of warnings are activated or not. (Rafael)
5a093634 458
74bb26f2
RGS
459Duping a filehandle which has the C<:utf8> PerlIO layer set will now
460properly carry that layer on the duped filehandle. (Rafael)
461
37a7450d 462Localizing an hash element whose key was given as a variable didn't work
21e0a455
RGS
463correctly if the variable was changed while the local() was in effect (as
464in C<local $h{$x}; ++$x>). (Bo Lindbergh)
37a7450d 465
f6eae373
RGS
466=head1 New or Changed Diagnostics
467
74bb26f2
RGS
468=head2 Deprecations
469
470Two deprecation warnings have been added: (Rafael)
471
472 Opening dirhandle %s also as a file
473 Opening filehandle %s also as a directory
474
f6eae373
RGS
475=head1 Changed Internals
476
73966613
RGS
477The anonymous hash and array constructors now take 1 op in the optree
478instead of 3, now that pp_anonhash and pp_anonlist return a reference to
479an hash/array when the op is flagged with OPf_SPECIAL (Nicholas Clark).
480
97f820fb
RGS
481=for p5p XXX have we some docs on how to create regexp engine plugins, since that's now possible ? (perlreguts)
482
483=for p5p XXX new BIND SV type, #29544, #29642
484
f6eae373
RGS
485=head1 Known Problems
486
487=head2 Platform Specific Problems
488
489=head1 Reporting Bugs
490
491If you find what you think is a bug, you might check the articles
492recently posted to the comp.lang.perl.misc newsgroup and the perl
493bug database at http://rt.perl.org/rt3/ . There may also be
494information at http://www.perl.org/ , the Perl Home Page.
495
496If you believe you have an unreported bug, please run the B<perlbug>
497program included with your release. Be sure to trim your bug down
498to a tiny but sufficient test case. Your bug report, along with the
499output of C<perl -V>, will be sent off to perlbug@perl.org to be
500analysed by the Perl porting team.
501
502=head1 SEE ALSO
503
504The F<Changes> file for exhaustive details on what changed.
505
506The F<INSTALL> file for how to build Perl.
507
508The F<README> file for general stuff.
509
510The F<Artistic> and F<Copying> files for copyright information.
511
512=cut