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