Commit | Line | Data |
496c75d0 |
1 | =head1 NAME |
2 | |
3 | perldelta - what is new for perl v5.9.3 |
4 | |
5 | =head1 DESCRIPTION |
6 | |
7 | This document describes differences between the 5.9.2 and the 5.9.3 |
d7f8936a |
8 | development releases. See L<perl590delta>, L<perl591delta> and |
496c75d0 |
9 | L<perl592delta> for the differences between 5.8.0 and 5.9.2. |
10 | |
11 | =head1 Incompatible Changes |
12 | |
2770530f |
13 | =head2 Parsing of C<-f _> |
14 | |
35cdf2f9 |
15 | The identifier C<_> is now forced to be a bareword after a filetest |
16 | operator. This solves a number of misparsing issues when a global C<_> |
17 | subroutine is defined. |
2770530f |
18 | |
78ef48ad |
19 | =head2 C<mkdir()> |
20 | |
21 | C<mkdir()> without arguments now defaults to C<$_>. |
22 | |
23 | =head2 Magic goto and eval |
24 | |
25 | The construct C<eval { goto &foo }> is now disallowed. (Note that the |
26 | similar construct, but with C<eval("")> instead, was already forbidden.) |
27 | |
28 | =head2 C<$#> has been removed |
29 | |
30 | The deprecated C<$#> variable (output format for numbers) has been |
31 | removed. A new warning, C<$# is no longer supported>, has been added. |
32 | |
33 | =head2 C<:unique> |
34 | |
8f7e634e |
35 | The C<:unique> attribute has been made a no-op, since its current |
78ef48ad |
36 | implementation was fundamentally flawed and not threadsafe. |
37 | |
e603cea9 |
38 | =head2 Scoping of the C<sort> pragma |
39 | |
40 | The C<sort> pragma is now lexically scoped. Its effect used to be global. |
41 | |
496c75d0 |
42 | =head1 Core Enhancements |
43 | |
e603cea9 |
44 | =head2 The C<feature> pragma |
45 | |
46 | The C<feature> pragma is used to enable new syntax that would break Perl's |
35cdf2f9 |
47 | backwards-compatibility with older releases of the language. It's a lexical |
e603cea9 |
48 | pragma, like C<strict> or C<warnings>. |
49 | |
50 | Currently the following new features are available: C<switch> (adds a |
51 | switch statement), C<~~> (adds a Perl 6-like smart match operator), C<say> |
52 | (adds a C<say> built-in function), and C<err> (adds an C<err> keyword). |
53 | Those features are described below. |
54 | |
55 | Note that C<err> low-precedence defined-or operator used to be enabled by |
35cdf2f9 |
56 | default (although as a weak keyword, meaning that any function would |
57 | override it). It's now only recognized when explicitly turned on (and is |
58 | then a regular keyword). |
59 | |
60 | Those features, and the C<feature> pragma itself, have been contributed by |
61 | Robin Houston. |
e603cea9 |
62 | |
78ef48ad |
63 | =head2 Switch and Smart Match operator |
64 | |
35cdf2f9 |
65 | Perl 5 now has a switch statement. It's available when C<use feature |
66 | 'switch'> is in effect. This feature introduces three new keywords, |
67 | C<given>, C<when>, and C<default> : |
68 | |
69 | given ($foo) { |
70 | when (/^abc/) { $abc = 1; } |
71 | when (/^def/) { $def = 1; } |
72 | when (/^xyz/) { $xyz = 1; } |
73 | default { $nothing = 1; } |
74 | } |
75 | |
76 | A more complete description of how Perl matches the switch variable |
77 | against the C<when> conditions is given in L<perlsyn/"Switch statements">. |
78 | |
79 | This kind of match is called I<smart match>, and it's also possible to use |
80 | it outside of switch statements, via the new C<~~> operator (enabled via |
81 | the C<use feature '~~'> directive). See L<perlsyn/"Smart matching in |
82 | detail">. |
e603cea9 |
83 | |
78ef48ad |
84 | =head2 C<say()> |
85 | |
409c2c5b |
86 | say() is a new built-in, only available when C<use feature 'say'> is in |
e603cea9 |
87 | effect, that is similar to print(), but that implicitly appends a newline |
88 | to the printed string. See L<perlfunc/say>. |
89 | |
78ef48ad |
90 | =head2 C<CLONE_SKIP()> |
91 | |
92 | Perl has now support for the C<CLONE_SKIP> special subroutine. Like |
93 | C<CLONE>, C<CLONE_SKIP> is called once per package; however, it is called |
94 | just before cloning starts, and in the context of the parent thread. If it |
95 | returns a true value, then no objects of that class will be cloned. See |
35cdf2f9 |
96 | L<perlmod> for details. (Contributed by Dave Mitchell.) |
78ef48ad |
97 | |
98 | =head2 C<${^CHILD_ERROR_NATIVE}> |
99 | |
100 | A new internal variable, C<${^CHILD_ERROR_NATIVE}>, gives the native |
101 | status returned by the last pipe close, backtick command, successful call |
102 | to wait() or waitpid(), or from the system() operator. See L<perlrun> for |
35cdf2f9 |
103 | details. (Contributed by Gisle Aas.) |
78ef48ad |
104 | |
105 | =head2 Assertions |
106 | |
107 | The support for assertions, introduced in perl 5.9.0, has been improved. |
108 | The syntax for the C<-A> command-line switch has changed; it now accepts |
109 | an optional module name, defaulting to C<assertions::activate>. See |
35cdf2f9 |
110 | L<assertions> and L<perlrun>. (Contributed by Salvador Fandiño García.) |
78ef48ad |
111 | |
112 | =head2 Unicode Character Database 4.1.0 |
113 | |
114 | The copy of the Unicode Character Database included in Perl 5.9 has |
115 | been updated to 4.1.0. |
116 | |
8f7e634e |
117 | =head2 C<no VERSION> |
118 | |
119 | You can now use C<no> followed by a version number to specify that you |
120 | want to use a version of perl inferior to the specified one. |
121 | |
e603cea9 |
122 | =head2 Recursive sort subs |
123 | |
ebab5fdd |
124 | You can now use recursive subroutines with sort(), thanks to Robin Houston. |
e603cea9 |
125 | |
126 | =head2 Effect of pragmas in eval |
127 | |
128 | The compile-time value of the C<%^H> hint variable can now propagate into |
129 | eval("")uated code. This makes it more useful to implement lexical |
130 | pragmas. |
131 | |
132 | As a side-effect of this, the overloaded-ness of constants now propagates |
133 | into eval(""). |
134 | |
135 | =head2 New B<-E> command-line switch |
136 | |
137 | B<-E> is equivalent to B<-e>, but it implicitly enables all |
35cdf2f9 |
138 | optional features (like C<use feature ":5.10">). |
e603cea9 |
139 | |
ebab5fdd |
140 | =head2 C<chdir>, C<chmod> and C<chown> on filehandles |
141 | |
142 | C<chdir>, C<chmod> and C<chown> can now work on filehandles as well as |
143 | filenames, if the system supports respectively C<fchdir>, C<fchmod> and |
144 | C<fchown>, thanks to a patch provided by Gisle Aas. |
145 | |
35cdf2f9 |
146 | =head2 OS groups |
147 | |
148 | C<$(> and C<$)> now return groups in the order where the OS returns them, |
149 | thanks to Gisle Aas. This wasn't previously the case. |
150 | |
496c75d0 |
151 | =head1 Modules and Pragmata |
152 | |
35cdf2f9 |
153 | =head2 New Core Modules |
154 | |
155 | =over 4 |
156 | |
157 | =item * |
158 | |
159 | A new pragma, C<feature>, has been added; see above in L</"Core |
160 | Enhancements">. |
161 | |
162 | =item * |
163 | |
164 | C<assertions::compat>, also available on CPAN, allows to use assertions on |
165 | perl versions prior to 5.9.0 (that is the first one to natively support |
166 | them). |
167 | |
168 | =item * |
169 | |
170 | C<Math::BigInt::FastCalc> is an XS-enabled, and thus faster, version of |
171 | C<Math::BigInt::Calc>. |
172 | |
173 | =item * |
174 | |
175 | C<Compress::Zlib> is an interface to the zlib compression library. It |
176 | comes with a bundled version of zlib, so having a working zlib is not a |
177 | prerequisite to install it. It's used by C<Archive::Tar> (see below). |
178 | |
179 | =item * |
78ef48ad |
180 | |
35cdf2f9 |
181 | C<IO::Zlib> is an C<IO::>-style interface to C<Compress::Zlib>. |
e603cea9 |
182 | |
35cdf2f9 |
183 | =item * |
78ef48ad |
184 | |
35cdf2f9 |
185 | C<Archive::Tar> is a module to manipulate C<tar> archives. |
78ef48ad |
186 | |
35cdf2f9 |
187 | =item * |
78ef48ad |
188 | |
35cdf2f9 |
189 | C<Digest::SHA> is a module used to calculate many types of SHA digests, |
190 | has been included for SHA support in the CPAN module. |
78ef48ad |
191 | |
35cdf2f9 |
192 | =back |
78ef48ad |
193 | |
496c75d0 |
194 | =head1 Utility Changes |
195 | |
78ef48ad |
196 | =head2 C<ptar> |
197 | |
35cdf2f9 |
198 | C<ptar> is a pure perl implementation of C<tar>, that comes with |
199 | C<Archive::Tar>. |
200 | |
201 | =head2 C<shasum> |
202 | |
203 | This command-line utility, used to print or to check SHA digests, comes |
204 | with the new C<Digest::SHA> module. |
205 | |
206 | =head2 C<h2xs> enhancements |
207 | |
208 | C<h2xs> implements new option C<--use-xsloader> to force use of |
209 | C<XSLoader> even in backwards compatible modules. |
210 | |
211 | The handling of authors' names that had apostrophes has been fixed. |
212 | |
213 | Any enums with negative values are now skipped. |
214 | |
215 | =head2 C<perlivp> enhancements |
216 | |
409c2c5b |
217 | C<perlivp> no longer checks for F<*.ph> files by default. Use the new C<-a> |
218 | option to run I<all> tests. |
35cdf2f9 |
219 | |
496c75d0 |
220 | =head1 Documentation |
221 | |
8f7e634e |
222 | =head2 Perl Glossary |
223 | |
224 | The L<perlglossary> manpage is a glossary of terms used in the Perl |
35cdf2f9 |
225 | documentation, technical and otherwise, kindly provided by O'Reilly Media, |
226 | inc. |
8f7e634e |
227 | |
496c75d0 |
228 | =head1 Performance Enhancements |
229 | |
e603cea9 |
230 | =head2 XS-assisted SWASHGET |
231 | |
232 | Some pure-perl code that perl was using to retrieve Unicode properties and |
ffabe59c |
233 | transliteration mappings has been reimplemented in XS. |
e603cea9 |
234 | |
35cdf2f9 |
235 | =head2 Constant subroutines |
e603cea9 |
236 | |
237 | XXX |
238 | |
ebab5fdd |
239 | =head2 C<PERL_DONT_CREATE_GVSV> |
240 | |
241 | The new compilation flag C<PERL_DONT_CREATE_GVSV>, introduced as an option |
242 | in perl 5.8.8, is turned on by default in perl 5.9.3. It prevents perl |
243 | from creating an empty scalar with every new typeglob. See L<perl588delta> |
244 | for details. |
245 | |
246 | =head2 Weak references are cheaper |
247 | |
248 | Weak reference creation is now I<O(1)> rather than I<O(n)>, courtesy of |
249 | Nicholas Clark. Weak reference deletion remains I<O(n)>, but if deletion only |
250 | happens at program exit, it may be skipped completely. |
251 | |
252 | =head2 sort() enhancements |
253 | |
254 | Salvador Fandiño provided improvements to reduce the memory usage of C<sort> |
255 | and to speed up some cases. |
256 | |
496c75d0 |
257 | =head1 Installation and Configuration Improvements |
258 | |
35cdf2f9 |
259 | =head2 Compilation improvements |
260 | |
261 | Parallel makes should work properly now, although there may still be problems |
262 | if C<make test> is instructed to run in parallel. |
263 | |
264 | Building with Borland's compilers on Win32 should work more smoothly. In |
265 | particular Steve Hay has worked to side step many warnings emitted by their |
266 | compilers and at least one C compiler internal error. |
267 | |
268 | Perl extensions on Windows now can be statically built into the Perl DLL, |
269 | thanks to a work by Vadim Konovalov. |
270 | |
78ef48ad |
271 | =head2 New Or Improved Platforms |
272 | |
273 | Perl is being ported to Symbian OS. See L<perlsymbian> for more |
274 | information. |
275 | |
e603cea9 |
276 | The VMS port has been improved. See L<perlvms>. |
277 | |
278 | DynaLoader::dl_unload_file() now works on Windows. |
279 | |
280 | Portability of Perl on various recent compilers on Windows has been |
281 | improved (Borland C++, Visual C++ 7.0). |
282 | |
283 | =head2 New probes |
284 | |
35cdf2f9 |
285 | C<Configure> will now detect C<clearenv> and C<unsetenv>, thanks to a |
286 | patch from Alan Burlison. It will also probe for C<futimes> (and use it |
287 | internally if available), and whether C<sprintf> correctly returns the |
288 | length of the formatted string. |
e603cea9 |
289 | |
78ef48ad |
290 | =head2 Module auxiliary files |
291 | |
292 | README files and changelogs for CPAN modules bundled with perl are no |
293 | longer installed. |
294 | |
496c75d0 |
295 | =head1 Selected Bug Fixes |
296 | |
2e6a7e23 |
297 | =head2 C<defined $$x> |
298 | |
299 | C<use strict "refs"> was ignoring taking a hard reference in an argument |
300 | to defined(), as in : |
301 | |
302 | use strict "refs"; |
303 | my $x = "foo"; |
304 | if (defined $$x) {...} |
305 | |
306 | This now correctly produces the run-time error C<Can't use string as a |
307 | SCALAR ref while "strict refs" in use>. (However, C<defined @$foo> and |
308 | C<defined %$foo> are still allowed. Those constructs are discouraged |
309 | anyway.) |
310 | |
e603cea9 |
311 | =head2 Calling CORE::require() |
312 | |
313 | CORE::require() and CORE::do() were always parsed as require() and do() |
409c2c5b |
314 | when they were overridden. This is now fixed. |
e603cea9 |
315 | |
316 | =head2 Subscripts of slices |
317 | |
318 | You can now use a non-arrowed form for chained subscripts after a list |
319 | slice, like in: |
320 | |
321 | ({foo => "bar"})[0]{foo} |
322 | |
323 | This used to be a syntax error; a C<< -> >> was required. |
324 | |
325 | =head2 Remove over-optimisation |
326 | |
327 | Perl 5.9.2 introduced a change so that assignments of C<undef> to a |
328 | scalar, or of an empty list to an array or a hash, were optimised out. As |
329 | this could cause problems when C<goto> jumps were involved, this change |
330 | was backed out. |
331 | |
332 | =head2 sprintf() fixes |
333 | |
334 | Using the sprintf() function with some formats could lead to a buffer |
335 | overflow in some specific cases. This has been fixed, along with several |
336 | other bugs, notably in bound checking. |
337 | |
35cdf2f9 |
338 | In related fixes, it was possible for badly written code that did not follow |
339 | the documentation of C<Sys::Syslog> to have formatting vulnerabilities. |
340 | C<Sys::Syslog> has been changed to protect people from poor quality third |
341 | party code. |
342 | |
343 | =head2 no warnings 'category' works correctly with -w |
344 | |
345 | Previously when running with warnings enabled globally via C<-w>, selective |
346 | disabling of specific warning categories would actually turn off all warnings. |
347 | This is now fixed; now C<no warnings 'io';> will only turn off warnings in the |
348 | C<io> class. Previously it would erroneously turn off all warnings. |
e603cea9 |
349 | |
78ef48ad |
350 | =head2 Smaller fixes |
351 | |
352 | =over 4 |
353 | |
354 | =item * |
355 | |
356 | C<FindBin> now works better with directories where access rights are more |
357 | restrictive than usual. |
358 | |
359 | =item * |
360 | |
e603cea9 |
361 | Several memory leaks in ithreads were closed. Also, ithreads were made |
362 | less memory-intensive. |
78ef48ad |
363 | |
364 | =item * |
365 | |
ebab5fdd |
366 | Trailing spaces are now trimmed from C<$!> and C<$^E>. |
367 | |
368 | =item * |
369 | |
370 | Operations that require perl to read a process' list of groups, such as reads |
371 | of C<$(> and C<$)>, now dynamically allocate memory rather than using a |
372 | fixed sized array. The fixed size array could cause C stack exhaustion on |
373 | systems configured to use large numbers of groups. |
374 | |
375 | =item * |
376 | |
78ef48ad |
377 | C<PerlIO::scalar> now works better with non-default C<$/> settings. |
378 | |
379 | =item * |
380 | |
ffabe59c |
381 | You can now use the C<x> operator to repeat a C<qw//> list. This used |
382 | to raise a syntax error. For example: C<qw(foo bar) x 3>. |
78ef48ad |
383 | |
e603cea9 |
384 | =item * |
385 | |
386 | The debugger now traces correctly execution in eval("")uated code that |
387 | contains #line directives. |
388 | |
389 | =item * |
390 | |
391 | The value of the C<open> pragma is no longer ignored for three-argument |
392 | opens. |
393 | |
394 | =item * |
395 | |
ebab5fdd |
396 | Perl will now use the C library calls C<unsetenv> and C<clearenv> if present |
397 | to delete keys from C<%ENV> and delete C<%ENV> entirely, thanks to a patch |
398 | from Alan Burlison. |
e603cea9 |
399 | |
78ef48ad |
400 | =back |
401 | |
402 | =head2 More Unicode Fixes |
403 | |
404 | =over 4 |
405 | |
406 | =item * |
407 | |
408 | chr() on a negative value now gives C<\x{FFFD}>, the Unicode replacement |
409 | character, unless when the C<bytes> pragma is in effect, where the low |
410 | eight bytes of the value are used. |
411 | |
ebab5fdd |
412 | =item * |
413 | |
414 | Some case insensitive matches between UTF-8 encoded data and 8 bit regexps, |
415 | and vice versa, could give malformed character warnings. These have been |
416 | fixed by Dave Mitchell and Yves Orton. |
417 | |
418 | =item * |
419 | |
420 | C<lcfirst> and C<ucfirst> could corrupt the string for certain cases where |
421 | the length UTF-8 encoding of the string in lower case, upper case or title |
422 | case differed. This was fixed by Nicholas Clark. |
423 | |
78ef48ad |
424 | =back |
425 | |
496c75d0 |
426 | =head1 New or Changed Diagnostics |
427 | |
78ef48ad |
428 | =head2 Attempt to set length of freed array |
429 | |
430 | This is a new warning, produced in situations like the following one: |
431 | |
432 | $r = do {my @a; \$#a}; |
433 | $$r = 503; |
434 | |
35cdf2f9 |
435 | =head2 Non-string passed as bitmask |
436 | |
437 | This is a new warning, produced when number has been passed as a argument to |
438 | select(), instead of a bitmask. |
439 | |
440 | # Wrong, will now warn |
441 | $rin = fileno(STDIN); |
442 | ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout); |
443 | |
444 | # Should be |
445 | $rin = ''; |
446 | vec($rin,fileno(STDIN),1) = 1; |
447 | ($nfound,$timeleft) = select($rout=$rin, undef, undef, $timeout); |
448 | |
78ef48ad |
449 | =head2 Search pattern not terminated or ternary operator parsed as search pattern |
450 | |
451 | This syntax error indicates that the lexer couldn't find the final |
452 | delimiter of a C<?PATTERN?> construct. Mentioning the ternary operator in |
453 | this error message makes syntax diagnostic easier. |
454 | |
8f7e634e |
455 | =head2 "%s" variable %s masks earlier declaration |
456 | |
457 | This warning is now emitted in more consistent cases; in short, when one |
458 | of the declarations involved is a C<my> variable: |
459 | |
460 | my $x; my $x; # warns |
461 | my $x; our $x; # warns |
462 | our $x; my $x; # warns |
463 | |
464 | On the other hand, the following : |
465 | |
466 | our $x; our $x; |
467 | |
468 | now gives a C<"our" variable %s redeclared> warning. |
469 | |
e603cea9 |
470 | =head2 readdir()/closedir()/etc. attempted on invalid dirhandle |
471 | |
472 | These new warnings are now emitted when a dirhandle is used but is |
473 | either closed or not really a dirhandle. |
474 | |
496c75d0 |
475 | =head1 Changed Internals |
476 | |
35cdf2f9 |
477 | In general, the source code of perl has been refactored, tied up, and |
478 | optimized in many places. Also, memory management and allocation has been |
479 | improved in a couple of points. |
480 | |
481 | Andy Lester supplied many improvements to determine which function |
482 | parameters and local variables could actually be declared C<const> to the C |
483 | compiler. Steve Peters provided new C<*_set> macros and reworked the core to |
484 | use these rather than assigning to macros in LVALUE context. |
485 | |
486 | Dave Mitchell improved the lexer debugging output under C<-DT>. |
78ef48ad |
487 | |
e603cea9 |
488 | A new file, F<mathoms.c>, has been added. It contains functions that are |
489 | no longer used in the perl core, but that remain available for binary or |
490 | source compatibility reasons. However, those functions will not be |
ffabe59c |
491 | compiled in if you add C<-DNO_MATHOMS> in the compiler flags. |
78ef48ad |
492 | |
493 | The C<AvFLAGS> macro has been removed. |
494 | |
ebab5fdd |
495 | The C<av_*()> functions, used to manipulate arrays, no longer accept null |
496 | C<AV*> parameters. |
497 | |
78ef48ad |
498 | =head2 B:: modules inheritance changed |
499 | |
500 | The inheritance hierarchy of C<B::> modules has changed; C<B::NV> now |
501 | inherits from C<B::SV> (it used to inherit from C<B::IV>). |
502 | |
496c75d0 |
503 | =head1 Known Problems |
504 | |
505 | =head2 Platform Specific Problems |
506 | |
507 | =head1 Reporting Bugs |
508 | |
509 | If you find what you think is a bug, you might check the articles |
510 | recently posted to the comp.lang.perl.misc newsgroup and the perl |
511 | bug database at http://bugs.perl.org/ . There may also be |
512 | information at http://www.perl.org/ , the Perl Home Page. |
513 | |
514 | If you believe you have an unreported bug, please run the B<perlbug> |
515 | program included with your release. Be sure to trim your bug down |
516 | to a tiny but sufficient test case. Your bug report, along with the |
517 | output of C<perl -V>, will be sent off to perlbug@perl.org to be |
518 | analysed by the Perl porting team. |
519 | |
520 | =head1 SEE ALSO |
521 | |
522 | The F<Changes> file for exhaustive details on what changed. |
523 | |
524 | The F<INSTALL> file for how to build Perl. |
525 | |
526 | The F<README> file for general stuff. |
527 | |
528 | The F<Artistic> and F<Copying> files for copyright information. |
529 | |
530 | =cut |