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