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