Mention new lexical pragmas big* in perldelta
[p5sagit/p5-mst-13.2.git] / pod / perl595delta.pod
1 =head1 NAME
2
3 perldelta - what is new for perl v5.9.5
4
5 =head1 DESCRIPTION
6
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.
11
12 =head1 Incompatible Changes
13
14 =head2 Tainting and printf
15
16 When perl is run under taint mode, C<printf()> and C<sprintf()> will now
17 reject any tainted format argument. (Rafael Garcia-Suarez)
18
19 =head2 undef and signal handlers
20
21 Undefining or deleting a signal handler via C<undef $SIG{FOO}> is now
22 equivalent to setting it to C<'DEFAULT'>. (Rafael)
23
24 =head2 strictures and array/hash dereferencing in defined()
25
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.)
28 (Nicholas Clark)
29
30 (However, C<defined(@foo)> and C<defined(%bar)> are discouraged constructs
31 anyway.)
32
33 =head2 C<(?p{})> has been removed
34
35 The regular expression construct C<(?p{})>, which was deprecated in perl
36 5.8, has been removed. Use C<(??{})> instead. (Rafael)
37
38 =head2 Removal of the bytecode compiler and of perlcc
39
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.
46
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
49 B::Concise).
50
51 =head2 Removal of the JPL
52
53 The JPL (Java-Perl Linguo) has been removed from the perl sources tarball.
54
55 =head2 Recursive inheritance detected earlier
56
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.
59
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.
63
64 =head1 Core Enhancements
65
66 =head2 Regular expressions
67
68 =over 4
69
70 =item Recursive Patterns
71
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
74 read.
75
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:
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
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)
101
102 =item Named Capture Buffers
103
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.
109
110 Thus, to replace all doubled chars, one could write
111
112     s/(?<letter>.)\k<letter>/$+{letter}/g
113
114 Only buffers with defined contents will be "visible" in the C<%+> hash, so
115 it's possible to do something like
116
117     foreach my $name (keys %+) {
118         print "content of buffer '$name' is $+{$name}\n";
119     }
120
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
123 be many of them.
124
125 C<%+> and C<%-> are implemented as tied hashes through the new module
126 C<Tie::Hash::NamedCapture>.
127
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
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
136 would expect. This is considered a feature. :-) (Yves Orton)
137
138 =item Possessive Quantifiers
139
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)
146
147 =item Backtracking control verbs
148
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)
152
153 =item Relative backreferences
154
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)
159
160 =item C<\K> escape
161
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:
166
167   s/(foo)bar/$1/g
168
169 that can now be converted to
170
171   s/foo\Kbar//g
172
173 which is much more efficient. (Yves Orton)
174
175 =item Vertical and horizontal whitespace, and linebreak
176
177 Regular expressions now recognize the C<\v> and C<\h> escapes, that match
178 vertical and horizontal whitespace, respectively. C<\V> and C<\H>
179 logically match their complements.
180
181 C<\R> matches a generic linebreak, that is, vertical whitespace, plus
182 the multi-character sequence C<"\x0D\x0A">.
183
184 =back
185
186 =head2 The C<_> prototype
187
188 A new prototype character has been added. C<_> is equivalent to C<$> (it
189 denotes a scalar), but defaults to C<$_> if the corresponding argument
190 isn't supplied. Due to the optional nature of the argument, you can only
191 use it at the end of a prototype, or before a semicolon.
192
193 This has a small incompatible consequence: the prototype() function has
194 been adjusted to return C<_> for some built-ins in appropriate cases (for
195 example, C<prototype('CORE::rmdir')>). (Rafael)
196
197 =head2 UNITCHECK blocks
198
199 C<UNITCHECK>, a new special code block has been introduced, in addition to
200 C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
201
202 C<CHECK> and C<INIT> blocks, while useful for some specialized purposes,
203 are always executed at the transition between the compilation and the
204 execution of the main program, and thus are useless whenever code is
205 loaded at runtime. On the other hand, C<UNITCHECK> blocks are executed
206 just after the unit which defined them has been compiled. See L<perlmod>
207 for more information. (Alex Gough)
208
209 =head2 readpipe() is now overridable
210
211 The built-in function readpipe() is now overridable. Overriding it permits
212 also to override its operator counterpart, C<qx//> (a.k.a. C<``>).
213 Moreover, it now defaults to C<$_> if no argument is provided. (Rafael)
214
215 =head2 default argument for readline()
216
217 readline() now defaults to C<*ARGV> if no argument is provided. (Rafael)
218
219 =head2 UCD 5.0.0
220
221 The copy of the Unicode Character Database included in Perl 5.9 has
222 been updated to version 5.0.0.
223
224 =head2 Smart match
225
226 The smart match operator (C<~~>) is now available by default (you don't
227 need to enable it with C<use feature> any longer). (Michael G Schwern)
228
229 =head2 Implicit loading of C<feature>
230
231 The C<feature> pragma is now implicitly loaded when you require a minimal
232 perl version (with the C<use VERSION> construct) greater than, or equal
233 to, 5.9.5.
234
235 =head1 Modules and Pragmas
236
237 =head2 New Pragma, C<mro>
238
239 A new pragma, C<mro> (for Method Resolution Order) has been added. It
240 permits to switch, on a per-class basis, the algorithm that perl uses to
241 find inherited methods in case of a mutiple inheritance hierachy. The
242 default MRO hasn't changed (DFS, for Depth First Search). Another MRO is
243 available: the C3 algorithm. See L<mro> for more information.
244 (Brandon Black)
245
246 =head2 bignum, bigint, bigrat
247
248 The three numeric pragmas C<bignum>, C<bigint> and C<bigrat> are now
249 lexically scoped. (Tels)
250
251 =head2 New Core Modules
252
253 =over 4
254
255 =item *
256
257 C<Locale::Maketext::Simple>, needed by CPANPLUS, is a simple wrapper around
258 C<Locale::Maketext::Lexicon>. Note that C<Locale::Maketext::Lexicon> isn't
259 included in the perl core; the behaviour of C<Locale::Maketext::Simple>
260 gracefully degrades when the later isn't present.
261
262 =item *
263
264 C<Params::Check> implements a generic input parsing/checking mechanism. It
265 is used by CPANPLUS.
266
267 =item *
268
269 C<Term::UI> simplifies the task to ask questions at a terminal prompt.
270
271 =item *
272
273 C<Object::Accessor> provides an interface to create per-object accessors.
274
275 =item *
276
277 C<Module::Pluggable> is a simple framework to create modules that accept
278 pluggable sub-modules.
279
280 =item *
281
282 C<Module::Load::Conditional> provides simple ways to query and possibly
283 load installed modules.
284
285 =item *
286
287 C<Time::Piece> provides an object oriented interface to time functions,
288 overriding the built-ins localtime() and gmtime().
289
290 =item *
291
292 C<IPC::Cmd> helps to find and run external commands, possibly
293 interactively.
294
295 =item *
296
297 C<File::Fetch> provide a simple generic file fetching mechanism.
298
299 =item *
300
301 C<Archive::Extract> is a generic archive extraction mechanism
302 for F<.tar> (plain, gziped or bzipped) or F<.zip> files.
303
304 =item *
305
306 C<CPANPLUS> provides an API and a command-line tool to access the CPAN
307 mirrors.
308
309 =back
310
311 =head2 Module changes
312
313 =over 4
314
315 =item C<base>
316
317 The C<base> pragma now warns if a class tries to inherit from itself.
318 (Curtis "Ovid" Poe)
319
320 =item C<strict> and C<warnings>
321
322 C<strict> and C<warnings> will now complain loudly if they are loaded via
323 incorrect casing (as in C<use Strict;>). (Johan Vromans)
324
325 =item C<warnings>
326
327 The C<warnings> pragma doesn't load C<Carp> anymore. That means that code
328 that used C<Carp> routines without having loaded it at compile time might
329 need to be adjusted; typically, the following (faulty) code won't work
330 anymore, and will require parentheses to be added after the function name:
331
332     use warnings;
333     require Carp;
334     Carp::confess "argh";
335
336 =item C<less>
337
338 C<less> now does something useful (or at least it tries to). In fact, it
339 has been turned into a lexical pragma. So, in your modules, you can now
340 test whether your users have requested to use less CPU, or less memory,
341 less magic, or maybe even less fat. See L<less> for more. (Joshua ben
342 Jore)
343
344 =item C<Attribute::Handlers>
345
346 C<Attribute::Handlers> can now report the caller's file and line number.
347 (David Feldman)
348
349 =item C<B::Lint>
350
351 C<B::Lint> is now based on C<Module::Pluggable>, and so can be extended
352 with plugins. (Joshua ben Jore)
353
354 =item C<B>
355
356 It's now possible to access the lexical pragma hints (C<%^H>) by using the
357 method B::COP::hints_hash(). It returns a C<B::RHE> object, which in turn
358 can be used to get a hash reference via the method B::RHE::HASH(). (Joshua
359 ben Jore)
360
361 =for p5p XXX document this in B.pm too
362
363 =item C<Thread>
364
365 As the old 5005thread threading model has been removed, in favor of the
366 ithreads scheme, the C<Thread> module is now a compatibility wrapper, to
367 be used in old code only.
368
369 =back
370
371 =head1 Utility Changes
372
373 =head2 C<cpanp>
374
375 C<cpanp>, the CPANPLUS shell, has been added. (C<cpanp-run-perl>, an
376 helper for CPANPLUS operation, has been added too, but isn't intended for
377 direct use).
378
379 =head2 C<cpan2dist>
380
381 C<cpan2dist> is a new utility, that comes with CPANPLUS. It's a tool to
382 create distributions (or packages) from CPAN modules.
383
384 =head2 C<pod2html>
385
386 The output of C<pod2html> has been enhanced to be more customizable via
387 CSS. Some formatting problems were also corrected. (Jari Aalto)
388
389 =head1 Documentation
390
391 =head2 New manpage, perlunifaq
392
393 A new manual page, L<perlunifaq> (the Perl Unicode FAQ), has been added
394 (Juerd Waalboer).
395
396 =head1 Performance Enhancements
397
398 =head1 Installation and Configuration Improvements
399
400 =head2 C++ compatibility
401
402 Efforts have been made to make perl and the core XS modules compilable
403 with various C++ compilers (although the situation is not perfect with
404 some of the compilers on some of the platforms tested.)
405
406 =head2 Visual C++
407
408 Perl now can be compiled with Microsoft Visual C++ 2005.
409
410 =head2 Static build on Win32
411
412 It's now possible to build a C<perl-static.exe> that doesn't depend
413 on C<perl59.dll> on Win32. See the Win32 makefiles for details.
414 (Vadim Konovalov)
415
416 =head2 C<d_pseudofork>
417
418 A new configuration variable, available as C<$Config{d_pseudofork}> in
419 the L<Config> module, has been added, to distinguish real fork() support
420 from fake pseudofork used on Windows platforms.
421
422 =head2 Ports
423
424 Perl has been reported to work on MidnightBSD.
425
426 =head1 Selected Bug Fixes
427
428 PerlIO::scalar will now prevent writing to read-only scalars. Moreover,
429 seek() is now supported with PerlIO::scalar-based filehandles, the
430 underlying string being zero-filled as needed. (Rafael, Jarkko Hietaniemi)
431
432 study() never worked for UTF-8 strings, but could lead to false results.
433 It's now a no-op on UTF-8 data. (Yves Orton)
434
435 The signals SIGILL, SIGBUS and SIGSEGV are now always delivered in an
436 "unsafe" manner (contrary to other signals, that are deferred until the
437 perl interpreter reaches a reasonably stable state; see
438 L<perlipc/"Deferred Signals (Safe Signals)">). (Rafael)
439
440 When a module or a file is loaded through an @INC-hook, and when this hook
441 has set a filename entry in %INC, __FILE__ is now set for this module
442 accordingly to the contents of that %INC entry. (Rafael)
443
444 The C<-w> and C<-t> switches can now be used together without messing
445 up what categories of warnings are activated or not. (Rafael)
446
447 Duping a filehandle which has the C<:utf8> PerlIO layer set will now
448 properly carry that layer on the duped filehandle. (Rafael)
449
450 =head1 New or Changed Diagnostics
451
452 =head2 Deprecations
453
454 Two deprecation warnings have been added: (Rafael)
455
456     Opening dirhandle %s also as a file
457     Opening filehandle %s also as a directory
458
459 =head1 Changed Internals
460
461 The anonymous hash and array constructors now take 1 op in the optree
462 instead of 3, now that pp_anonhash and pp_anonlist return a reference to
463 an hash/array when the op is flagged with OPf_SPECIAL (Nicholas Clark).
464
465 =for p5p XXX have we some docs on how to create regexp engine plugins, since that's now possible ? (perlreguts)
466
467 =for p5p XXX new BIND SV type, #29544, #29642
468
469 =head1 Known Problems
470
471 =head2 Platform Specific Problems
472
473 =head1 Reporting Bugs
474
475 If you find what you think is a bug, you might check the articles
476 recently posted to the comp.lang.perl.misc newsgroup and the perl
477 bug database at http://rt.perl.org/rt3/ .  There may also be
478 information at http://www.perl.org/ , the Perl Home Page.
479
480 If you believe you have an unreported bug, please run the B<perlbug>
481 program included with your release.  Be sure to trim your bug down
482 to a tiny but sufficient test case.  Your bug report, along with the
483 output of C<perl -V>, will be sent off to perlbug@perl.org to be
484 analysed by the Perl porting team.
485
486 =head1 SEE ALSO
487
488 The F<Changes> file for exhaustive details on what changed.
489
490 The F<INSTALL> file for how to build Perl.
491
492 The F<README> file for general stuff.
493
494 The F<Artistic> and F<Copying> files for copyright information.
495
496 =cut