This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: overload64.t failures
[perl5.git] / pod / perl5100delta.pod
CommitLineData
cf6c151c
RGS
1=head1 NAME
2
3perldelta - what is new for perl 5.10.0
4
5=head1 DESCRIPTION
6
7This document describes the differences between the 5.8.8 release and
8the 5.10.0 release.
9
10Many of the bug fixes in 5.10.0 were already seen in the 5.8.X maintenance
11releases; they are not duplicated here and are documented in the set of
12man pages named perl58[1-8]?delta.
13
cf6c151c
RGS
14=head1 Core Enhancements
15
16=head2 The C<feature> pragma
17
18The C<feature> pragma is used to enable new syntax that would break Perl's
19backwards-compatibility with older releases of the language. It's a lexical
20pragma, like C<strict> or C<warnings>.
21
22Currently the following new features are available: C<switch> (adds a
23switch statement), C<say> (adds a C<say> built-in function), and C<state>
24(adds an C<state> keyword for declaring "static" variables). Those
25features are described in their own sections of this document.
26
27The C<feature> pragma is also implicitly loaded when you require a minimal
28perl version (with the C<use VERSION> construct) greater than, or equal
29to, 5.9.5. See L<feature> for details.
30
31=head2 New B<-E> command-line switch
32
33B<-E> is equivalent to B<-e>, but it implicitly enables all
34optional features (like C<use feature ":5.10">).
35
36=head2 Defined-or operator
37
38A new operator C<//> (defined-or) has been implemented.
39The following statement:
40
41 $a // $b
42
43is merely equivalent to
44
45 defined $a ? $a : $b
46
47and
48
49 $c //= $d;
50
51can now be used instead of
52
53 $c = $d unless defined $c;
54
55The C<//> operator has the same precedence and associativity as C<||>.
56Special care has been taken to ensure that this operator Do What You Mean
57while not breaking old code, but some edge cases involving the empty
58regular expression may now parse differently. See L<perlop> for
59details.
60
61=head2 Switch and Smart Match operator
62
63Perl 5 now has a switch statement. It's available when C<use feature
64'switch'> is in effect. This feature introduces three new keywords,
65C<given>, C<when>, and C<default>:
66
67 given ($foo) {
68 when (/^abc/) { $abc = 1; }
69 when (/^def/) { $def = 1; }
70 when (/^xyz/) { $xyz = 1; }
71 default { $nothing = 1; }
72 }
73
74A more complete description of how Perl matches the switch variable
75against the C<when> conditions is given in L<perlsyn/"Switch statements">.
76
77This kind of match is called I<smart match>, and it's also possible to use
78it outside of switch statements, via the new C<~~> operator. See
79L<perlsyn/"Smart matching in detail">.
80
81This feature was contributed by Robin Houston.
82
83=head2 Regular expressions
84
85=over 4
86
87=item Recursive Patterns
88
89It is now possible to write recursive patterns without using the C<(??{})>
90construct. This new way is more efficient, and in many cases easier to
91read.
92
93Each capturing parenthesis can now be treated as an independent pattern
94that can be entered by using the C<(?PARNO)> syntax (C<PARNO> standing for
95"parenthesis number"). For example, the following pattern will match
96nested balanced angle brackets:
97
98 /
99 ^ # start of line
100 ( # start capture buffer 1
101 < # match an opening angle bracket
102 (?: # match one of:
103 (?> # don't backtrack over the inside of this group
104 [^<>]+ # one or more non angle brackets
105 ) # end non backtracking group
106 | # ... or ...
107 (?1) # recurse to bracket 1 and try it again
108 )* # 0 or more times.
109 > # match a closing angle bracket
110 ) # end capture buffer one
111 $ # end of line
112 /x
113
114Note, users experienced with PCRE will find that the Perl implementation
115of this feature differs from the PCRE one in that it is possible to
116backtrack into a recursed pattern, whereas in PCRE the recursion is
117atomic or "possessive" in nature. (Yves Orton)
118
119=item Named Capture Buffers
120
121It is now possible to name capturing parenthesis in a pattern and refer to
122the captured contents by name. The naming syntax is C<< (?<NAME>....) >>.
123It's possible to backreference to a named buffer with the C<< \k<NAME> >>
124syntax. In code, the new magical hashes C<%+> and C<%-> can be used to
125access the contents of the capture buffers.
126
127Thus, to replace all doubled chars, one could write
128
129 s/(?<letter>.)\k<letter>/$+{letter}/g
130
131Only buffers with defined contents will be "visible" in the C<%+> hash, so
132it's possible to do something like
133
134 foreach my $name (keys %+) {
135 print "content of buffer '$name' is $+{$name}\n";
136 }
137
138The C<%-> hash is a bit more complete, since it will contain array refs
139holding values from all capture buffers similarly named, if there should
140be many of them.
141
142C<%+> and C<%-> are implemented as tied hashes through the new module
143C<Tie::Hash::NamedCapture>.
144
145Users exposed to the .NET regex engine will find that the perl
146implementation differs in that the numerical ordering of the buffers
147is sequential, and not "unnamed first, then named". Thus in the pattern
148
149 /(A)(?<B>B)(C)(?<D>D)/
150
151$1 will be 'A', $2 will be 'B', $3 will be 'C' and $4 will be 'D' and not
152$1 is 'A', $2 is 'C' and $3 is 'B' and $4 is 'D' that a .NET programmer
153would expect. This is considered a feature. :-) (Yves Orton)
154
155=item Possessive Quantifiers
156
157Perl now supports the "possessive quantifier" syntax of the "atomic match"
158pattern. Basically a possessive quantifier matches as much as it can and never
159gives any back. Thus it can be used to control backtracking. The syntax is
160similar to non-greedy matching, except instead of using a '?' as the modifier
161the '+' is used. Thus C<?+>, C<*+>, C<++>, C<{min,max}+> are now legal
162quantifiers. (Yves Orton)
163
164=item Backtracking control verbs
165
166The regex engine now supports a number of special-purpose backtrack
167control verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)
168and (*ACCEPT). See L<perlre> for their descriptions. (Yves Orton)
169
170=item Relative backreferences
171
172A new syntax C<\g{N}> or C<\gN> where "N" is a decimal integer allows a
173safer form of back-reference notation as well as allowing relative
174backreferences. This should make it easier to generate and embed patterns
175that contain backreferences. See L<perlre/"Capture buffers">. (Yves Orton)
176
177=item C<\K> escape
178
179The functionality of Jeff Pinyan's module Regexp::Keep has been added to
180the core. You can now use in regular expressions the special escape C<\K>
181as a way to do something like floating length positive lookbehind. It is
182also useful in substitutions like:
183
184 s/(foo)bar/$1/g
185
186that can now be converted to
187
188 s/foo\Kbar//g
189
190which is much more efficient. (Yves Orton)
191
192=item Vertical and horizontal whitespace, and linebreak
193
194Regular expressions now recognize the C<\v> and C<\h> escapes, that match
195vertical and horizontal whitespace, respectively. C<\V> and C<\H>
196logically match their complements.
197
198C<\R> matches a generic linebreak, that is, vertical whitespace, plus
199the multi-character sequence C<"\x0D\x0A">.
200
201=back
202
203=head2 C<say()>
204
205say() is a new built-in, only available when C<use feature 'say'> is in
206effect, that is similar to print(), but that implicitly appends a newline
207to the printed string. See L<perlfunc/say>. (Robin Houston)
208
209=head2 Lexical C<$_>
210
211The default variable C<$_> can now be lexicalized, by declaring it like
212any other lexical variable, with a simple
213
214 my $_;
215
216The operations that default on C<$_> will use the lexically-scoped
217version of C<$_> when it exists, instead of the global C<$_>.
218
219In a C<map> or a C<grep> block, if C<$_> was previously my'ed, then the
220C<$_> inside the block is lexical as well (and scoped to the block).
221
222In a scope where C<$_> has been lexicalized, you can still have access to
223the global version of C<$_> by using C<$::_>, or, more simply, by
597bb945 224overriding the lexical declaration with C<our $_>. (Rafael Garcia-Suarez)
cf6c151c
RGS
225
226=head2 The C<_> prototype
227
228A new prototype character has been added. C<_> is equivalent to C<$> (it
229denotes a scalar), but defaults to C<$_> if the corresponding argument
230isn't supplied. Due to the optional nature of the argument, you can only
231use it at the end of a prototype, or before a semicolon.
232
233This has a small incompatible consequence: the prototype() function has
234been adjusted to return C<_> for some built-ins in appropriate cases (for
235example, C<prototype('CORE::rmdir')>). (Rafael Garcia-Suarez)
236
237=head2 UNITCHECK blocks
238
239C<UNITCHECK>, a new special code block has been introduced, in addition to
240C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
241
242C<CHECK> and C<INIT> blocks, while useful for some specialized purposes,
243are always executed at the transition between the compilation and the
244execution of the main program, and thus are useless whenever code is
245loaded at runtime. On the other hand, C<UNITCHECK> blocks are executed
246just after the unit which defined them has been compiled. See L<perlmod>
247for more information. (Alex Gough)
248
249=head2 New Pragma, C<mro>
250
251A new pragma, C<mro> (for Method Resolution Order) has been added. It
252permits to switch, on a per-class basis, the algorithm that perl uses to
253find inherited methods in case of a mutiple inheritance hierachy. The
254default MRO hasn't changed (DFS, for Depth First Search). Another MRO is
255available: the C3 algorithm. See L<mro> for more information.
256(Brandon Black)
257
258Note that, due to changes in the implentation of class hierarchy search,
259code that used to undef the C<*ISA> glob will most probably break. Anyway,
260undef'ing C<*ISA> had the side-effect of removing the magic on the @ISA
261array and should not have been done in the first place.
262
263=head2 readpipe() is now overridable
264
265The built-in function readpipe() is now overridable. Overriding it permits
266also to override its operator counterpart, C<qx//> (a.k.a. C<``>).
267Moreover, it now defaults to C<$_> if no argument is provided. (Rafael
268Garcia-Suarez)
269
597bb945 270=head2 Default argument for readline()
cf6c151c
RGS
271
272readline() now defaults to C<*ARGV> if no argument is provided. (Rafael
273Garcia-Suarez)
274
275=head2 state() variables
276
277A new class of variables has been introduced. State variables are similar
278to C<my> variables, but are declared with the C<state> keyword in place of
279C<my>. They're visible only in their lexical scope, but their value is
280persistent: unlike C<my> variables, they're not undefined at scope entry,
281but retain their previous value. (Rafael Garcia-Suarez, Nicholas Clark)
282
283To use state variables, one needs to enable them by using
284
285 use feature "state";
286
287or by using the C<-E> command-line switch in one-liners.
288See L<perlsub/"Persistent variables via state()">.
289
290=head2 Stacked filetest operators
291
292As a new form of syntactic sugar, it's now possible to stack up filetest
293operators. You can now write C<-f -w -x $file> in a row to mean
294C<-x $file && -w _ && -f _>. See L<perlfunc/-X>.
295
296=head2 UNIVERSAL::DOES()
297
298The C<UNIVERSAL> class has a new method, C<DOES()>. It has been added to
299solve semantic problems with the C<isa()> method. C<isa()> checks for
300inheritance, while C<DOES()> has been designed to be overridden when
301module authors use other types of relations between classes (in addition
302to inheritance). (chromatic)
303
304See L<< UNIVERSAL/"$obj->DOES( ROLE )" >>.
305
306=head2 C<CLONE_SKIP()>
307
308Perl has now support for the C<CLONE_SKIP> special subroutine. Like
309C<CLONE>, C<CLONE_SKIP> is called once per package; however, it is called
310just before cloning starts, and in the context of the parent thread. If it
311returns a true value, then no objects of that class will be cloned. See
312L<perlmod> for details. (Contributed by Dave Mitchell.)
313
314=head2 Formats
315
316Formats were improved in several ways. A new field, C<^*>, can be used for
317variable-width, one-line-at-a-time text. Null characters are now handled
318correctly in picture lines. Using C<@#> and C<~~> together will now
319produce a compile-time error, as those format fields are incompatible.
320L<perlform> has been improved, and miscellaneous bugs fixed.
321
322=head2 Byte-order modifiers for pack() and unpack()
323
324There are two new byte-order modifiers, C<E<gt>> (big-endian) and C<E<lt>>
325(little-endian), that can be appended to most pack() and unpack() template
326characters and groups to force a certain byte-order for that type or group.
327See L<perlfunc/pack> and L<perlpacktut> for details.
328
cf6c151c
RGS
329=head2 C<no VERSION>
330
331You can now use C<no> followed by a version number to specify that you
332want to use a version of perl older than the specified one.
333
334=head2 C<chdir>, C<chmod> and C<chown> on filehandles
335
336C<chdir>, C<chmod> and C<chown> can now work on filehandles as well as
337filenames, if the system supports respectively C<fchdir>, C<fchmod> and
338C<fchown>, thanks to a patch provided by Gisle Aas.
339
340=head2 OS groups
341
342C<$(> and C<$)> now return groups in the order where the OS returns them,
343thanks to Gisle Aas. This wasn't previously the case.
344
345=head2 Recursive sort subs
346
347You can now use recursive subroutines with sort(), thanks to Robin Houston.
348
349=head2 Exceptions in constant folding
350
351The constant folding routine is now wrapped in an exception handler, and
352if folding throws an exception (such as attempting to evaluate 0/0), perl
353now retains the current optree, rather than aborting the whole program.
354(Nicholas Clark, Dave Mitchell)
355
356=head2 Source filters in @INC
357
358It's possible to enhance the mechanism of subroutine hooks in @INC by
359adding a source filter on top of the filehandle opened and returned by the
360hook. This feature was planned a long time ago, but wasn't quite working
361until now. See L<perlfunc/require> for details. (Nicholas Clark)
362
363=head2 New internal variables
364
365=over 4
366
367=item C<${^RE_DEBUG_FLAGS}>
368
369This variable controls what debug flags are in effect for the regular
370expression engine when running under C<use re "debug">. See L<re> for
371details.
372
373=item C<${^CHILD_ERROR_NATIVE}>
374
375This variable gives the native status returned by the last pipe close,
376backtick command, successful call to wait() or waitpid(), or from the
377system() operator. See L<perlrun> for details. (Contributed by Gisle Aas.)
378
597bb945
RGS
379=item C<${^RE_TRIE_MAXBUF}>
380
381See L</"Trie optimisation of literal string alternations">.
382
383=item C<${^WIN32_SLOPPY_STAT}>
384
385See L</"Sloppy stat on Windows">.
386
cf6c151c
RGS
387=back
388
389=head2 Miscellaneous
390
391C<unpack()> now defaults to unpacking the C<$_> variable.
392
393C<mkdir()> without arguments now defaults to C<$_>.
394
395The internal dump output has been improved, so that non-printable characters
396such as newline and backspace are output in C<\x> notation, rather than
397octal.
398
399The B<-C> option can no longer be used on the C<#!> line. It wasn't
400working there anyway.
401
402=head2 UCD 5.0.0
403
404The copy of the Unicode Character Database included in Perl 5 has
405been updated to version 5.0.0.
406
cf6c151c
RGS
407=head2 MAD
408
409MAD, which stands for I<Misc Attribute Decoration>, is a
410still-in-development work leading to a Perl 5 to Perl 6 converter. To
411enable it, it's necessary to pass the argument C<-Dmad> to Configure. The
412obtained perl isn't binary compatible with a regular perl 5.9.4, and has
413space and speed penalties; moreover not all regression tests still pass
414with it. (Larry Wall, Nicholas Clark)
415
597bb945
RGS
416=head1 Incompatible Changes
417
418=head2 Packing and UTF-8 strings
419
420=for XXX update this
421
422The semantics of pack() and unpack() regarding UTF-8-encoded data has been
423changed. Processing is now by default character per character instead of
424byte per byte on the underlying encoding. Notably, code that used things
425like C<pack("a*", $string)> to see through the encoding of string will now
426simply get back the original $string. Packed strings can also get upgraded
427during processing when you store upgraded characters. You can get the old
428behaviour by using C<use bytes>.
429
430To be consistent with pack(), the C<C0> in unpack() templates indicates
431that the data is to be processed in character mode, i.e. character by
432character; on the contrary, C<U0> in unpack() indicates UTF-8 mode, where
433the packed string is processed in its UTF-8-encoded Unicode form on a byte
434by byte basis. This is reversed with regard to perl 5.8.X.
435
436Moreover, C<C0> and C<U0> can also be used in pack() templates to specify
437respectively character and byte modes.
438
439C<C0> and C<U0> in the middle of a pack or unpack format now switch to the
440specified encoding mode, honoring parens grouping. Previously, parens were
441ignored.
442
443Also, there is a new pack() character format, C<W>, which is intended to
444replace the old C<C>. C<C> is kept for unsigned chars coded as bytes in
445the strings internal representation. C<W> represents unsigned (logical)
446character values, which can be greater than 255. It is therefore more
447robust when dealing with potentially UTF-8-encoded data (as C<C> will wrap
448values outside the range 0..255, and not respect the string encoding).
449
450In practice, that means that pack formats are now encoding-neutral, except
451C<C>.
452
453For consistency, C<A> in unpack() format now trims all Unicode whitespace
454from the end of the string. Before perl 5.9.2, it used to strip only the
455classical ASCII space characters.
456
457=head2 Byte/character count feature in unpack()
458
459A new unpack() template character, C<".">, returns the number of bytes or
460characters (depending on the selected encoding mode, see above) read so far.
461
462=head2 The C<$*> and C<$#> variables have been removed
463
464C<$*>, which was deprecated in favor of the C</s> and C</m> regexp
465modifiers, has been removed.
466
467The deprecated C<$#> variable (output format for numbers) has been
468removed.
469
470Two new warnings, C<$#/$* is no longer supported>, have been added.
471
472=head2 substr() lvalues are no longer fixed-length
473
474The lvalues returned by the three argument form of substr() used to be a
475"fixed length window" on the original string. In some cases this could
476cause surprising action at distance or other undefined behaviour. Now the
477length of the window adjusts itself to the length of the string assigned to
478it.
479
480=head2 Parsing of C<-f _>
481
482The identifier C<_> is now forced to be a bareword after a filetest
483operator. This solves a number of misparsing issues when a global C<_>
484subroutine is defined.
485
486=head2 C<:unique>
487
488The C<:unique> attribute has been made a no-op, since its current
489implementation was fundamentally flawed and not threadsafe.
490
491=head2 Scoping of the C<sort> pragma
492
493The C<sort> pragma is now lexically scoped. Its effect used to be global.
494
495=head2 Scoping of C<bignum>, C<bigint>, C<bigrat>
496
497The three numeric pragmas C<bignum>, C<bigint> and C<bigrat> are now
498lexically scoped. (Tels)
499
500=head2 Effect of pragmas in eval
501
502The compile-time value of the C<%^H> hint variable can now propagate into
503eval("")uated code. This makes it more useful to implement lexical
504pragmas.
505
506As a side-effect of this, the overloaded-ness of constants now propagates
507into eval("").
508
509=head2 chdir FOO
510
511A bareword argument to chdir() is now recognized as a file handle.
512Earlier releases interpreted the bareword as a directory name.
513(Gisle Aas)
514
515=head2 Handling of .pmc files
516
517An old feature of perl was that before C<require> or C<use> look for a
518file with a F<.pm> extension, they will first look for a similar filename
519with a F<.pmc> extension. If this file is found, it will be loaded in
520place of any potentially existing file ending in a F<.pm> extension.
521
522Previously, F<.pmc> files were loaded only if more recent than the
523matching F<.pm> file. Starting with 5.9.4, they'll be always loaded if
524they exist.
525
526=head2 @- and @+ in patterns
527
528The special arrays C<@-> and C<@+> are no longer interpolated in regular
529expressions. (Sadahiro Tomoyuki)
530
531=head2 $AUTOLOAD can now be tainted
532
533If you call a subroutine by a tainted name, and if it defers to an
534AUTOLOAD function, then $AUTOLOAD will be (correctly) tainted.
535(Rick Delaney)
536
537=head2 Tainting and printf
538
539When perl is run under taint mode, C<printf()> and C<sprintf()> will now
540reject any tainted format argument. (Rafael Garcia-Suarez)
541
542=head2 undef and signal handlers
543
544Undefining or deleting a signal handler via C<undef $SIG{FOO}> is now
545equivalent to setting it to C<'DEFAULT'>. (Rafael Garcia-Suarez)
546
547=head2 strictures and dereferencing in defined()
548
549C<use strict "refs"> was ignoring taking a hard reference in an argument
550to defined(), as in :
551
552 use strict "refs";
553 my $x = "foo";
554 if (defined $$x) {...}
555
556This now correctly produces the run-time error C<Can't use string as a
557SCALAR ref while "strict refs" in use>.
558
559C<defined @$foo> and C<defined %$bar> are now also subject to C<strict
560'refs'> (that is, C<$foo> and C<$bar> shall be proper references there.)
561(C<defined(@foo)> and C<defined(%bar)> are discouraged constructs anyway.)
562(Nicholas Clark)
563
564=head2 C<(?p{})> has been removed
565
566The regular expression construct C<(?p{})>, which was deprecated in perl
5675.8, has been removed. Use C<(??{})> instead. (Rafael Garcia-Suarez)
568
569=head2 Pseudo-hashes have been removed
570
571Support for pseudo-hashes has been removed from Perl 5.9. (The C<fields>
572pragma remains here, but uses an alternate implementation.)
573
574=head2 Removal of the bytecode compiler and of perlcc
575
576C<perlcc>, the byteloader and the supporting modules (B::C, B::CC,
577B::Bytecode, etc.) are no longer distributed with the perl sources. Those
578experimental tools have never worked reliably, and, due to the lack of
579volunteers to keep them in line with the perl interpreter developments, it
580was decided to remove them instead of shipping a broken version of those.
581The last version of those modules can be found with perl 5.9.4.
582
583However the B compiler framework stays supported in the perl core, as with
584the more useful modules it has permitted (among others, B::Deparse and
585B::Concise).
586
587=head2 Removal of the JPL
588
589The JPL (Java-Perl Linguo) has been removed from the perl sources tarball.
590
591=head2 Recursive inheritance detected earlier
592
593Perl will now immediately throw an exception if you modify any package's
594C<@ISA> in such a way that it would cause recursive inheritance.
595
596Previously, the exception would not occur until Perl attempted to make
597use of the recursive inheritance while resolving a method or doing a
598C<$foo-E<gt>isa($bar)> lookup.
599
cf6c151c 600=head1 Modules and Pragmata
c0c97549 601
0eece9c0
RGS
602=head2 New modules
603
604=over 4
605
606=item *
607
608C<encoding::warnings>, by Audrey Tang, is a module to emit warnings
609whenever an ASCII character string containing high-bit bytes is implicitly
597bb945
RGS
610converted into UTF-8. It's a lexical pragma since Perl 5.9.4; on older
611perls, its effect is global.
0eece9c0
RGS
612
613=item *
614
615C<Module::CoreList>, by Richard Clamp, is a small handy module that tells
616you what versions of core modules ship with any versions of Perl 5. It
617comes with a command-line frontend, C<corelist>.
618
bd3831ee
RGS
619=item *
620
621C<Math::BigInt::FastCalc> is an XS-enabled, and thus faster, version of
622C<Math::BigInt::Calc>.
623
624=item *
625
626C<Compress::Zlib> is an interface to the zlib compression library. It
627comes with a bundled version of zlib, so having a working zlib is not a
628prerequisite to install it. It's used by C<Archive::Tar> (see below).
629
630=item *
631
632C<IO::Zlib> is an C<IO::>-style interface to C<Compress::Zlib>.
633
634=item *
635
636C<Archive::Tar> is a module to manipulate C<tar> archives.
637
638=item *
639
640C<Digest::SHA> is a module used to calculate many types of SHA digests,
641has been included for SHA support in the CPAN module.
642
643=item *
644
645C<ExtUtils::CBuilder> and C<ExtUtils::ParseXS> have been added.
646
597bb945
RGS
647=item *
648
649C<Hash::Util::FieldHash>, by Anno Siegel, has been added. This module
650provides support for I<field hashes>: hashes that maintain an association
651of a reference with a value, in a thread-safe garbage-collected way.
652Such hashes are useful to implement inside-out objects.
653
654=item *
655
656C<Module::Build>, by Ken Williams, has been added. It's an alternative to
657C<ExtUtils::MakeMaker> to build and install perl modules.
658
659=item *
660
661C<Module::Load>, by Jos Boumans, has been added. It provides a single
662interface to load Perl modules and F<.pl> files.
663
664=item *
665
666C<Module::Loaded>, by Jos Boumans, has been added. It's used to mark
667modules as loaded or unloaded.
668
669=item *
670
671C<Package::Constants>, by Jos Boumans, has been added. It's a simple
672helper to list all constants declared in a given package.
673
674=item *
675
676C<Win32API::File>, by Tye McQueen, has been added (for Windows builds).
677This module provides low-level access to Win32 system API calls for
678files/dirs.
679
0eece9c0
RGS
680=back
681
cf6c151c 682=head1 Utility Changes
c0c97549
RGS
683
684=over 4
685
bd3831ee 686=item perl -d
c0c97549
RGS
687
688The Perl debugger can now save all debugger commands for sourcing later;
689notably, it can now emulate stepping backwards, by restarting and
690rerunning all bar the last command from a saved command history.
691
692It can also display the parent inheritance tree of a given class, with the
693C<i> command.
694
695Perl has a new -dt command-line flag, which enables threads support in the
696debugger.
697
bd3831ee
RGS
698=item ptar
699
700C<ptar> is a pure perl implementation of C<tar>, that comes with
701C<Archive::Tar>.
702
703=item ptardiff
704
705C<ptardiff> is a small script used to generate a diff between the contents
706of a tar archive and a directory tree. Like C<ptar>, it comes with
707C<Archive::Tar>.
708
709=item shasum
710
711C<shasum> is a command-line utility, used to print or to check SHA
712digests. It comes with the new C<Digest::SHA> module.
713
714=item corelist
0eece9c0
RGS
715
716The C<corelist> utility is now installed with perl (see L</"New modules">
717above).
718
bd3831ee 719=item h2ph and h2xs
0eece9c0
RGS
720
721C<h2ph> and C<h2xs> have been made a bit more robust with regard to
722"modern" C code.
723
bd3831ee
RGS
724C<h2xs> implements a new option C<--use-xsloader> to force use of
725C<XSLoader> even in backwards compatible modules.
726
727The handling of authors' names that had apostrophes has been fixed.
728
729Any enums with negative values are now skipped.
730
731=item perlivp
732
733C<perlivp> no longer checks for F<*.ph> files by default. Use the new C<-a>
734option to run I<all> tests.
735
736=item find2perl
0eece9c0
RGS
737
738C<find2perl> now assumes C<-print> as a default action. Previously, it
739needed to be specified explicitly.
740
741Several bugs have been fixed in C<find2perl>, regarding C<-exec> and
742C<-eval>. Also the options C<-path>, C<-ipath> and C<-iname> have been
743added.
744
597bb945
RGS
745=item config_data
746
747C<config_data> is a new utility that comes with C<Module::Build>. It
748provides a command-line interface to the configuration of Perl modules
749that use Module::Build's framework of configurability (that is,
750C<*::ConfigData> modules that contain local configuration information for
751their parent modules.)
752
c0c97549
RGS
753=back
754
cf6c151c 755=head1 New Documentation
c0c97549 756
597bb945
RGS
757The L<perlpragma> manpage documents how to write one's own lexical
758pragmas in pure Perl (something that is possible starting with 5.9.4).
759
bd3831ee
RGS
760The new L<perlglossary> manpage is a glossary of terms used in the Perl
761documentation, technical and otherwise, kindly provided by O'Reilly Media,
762Inc.
763
597bb945
RGS
764The L<perlreguts> manpage, courtesy of Yves Orton, describes internals of the
765Perl regular expression engine.
766
767The L<perlunitut> manpage is an tutorial for programming with Unicode and
768string encodings in Perl, courtesy of Juerd Waalboer.
769
c0c97549
RGS
770The long-existing feature of C</(?{...})/> regexps setting C<$_> and pos()
771is now documented.
772
cf6c151c 773=head1 Performance Enhancements
c0c97549 774
597bb945 775=head2 In-place sorting
0eece9c0 776
c0c97549
RGS
777Sorting arrays in place (C<@a = sort @a>) is now optimized to avoid
778making a temporary copy of the array.
779
0eece9c0
RGS
780Likewise, C<reverse sort ...> is now optimized to sort in reverse,
781avoiding the generation of a temporary intermediate list.
782
597bb945 783=head2 Lexical array access
0eece9c0 784
c0c97549
RGS
785Access to elements of lexical arrays via a numeric constant between 0 and
786255 is now faster. (This used to be only the case for global arrays.)
787
597bb945 788=head2 XS-assisted SWASHGET
bd3831ee
RGS
789
790Some pure-perl code that perl was using to retrieve Unicode properties and
791transliteration mappings has been reimplemented in XS.
792
597bb945 793=head2 Constant subroutines
bd3831ee
RGS
794
795The interpreter internals now support a far more memory efficient form of
796inlineable constants. Storing a reference to a constant value in a symbol
797table is equivalent to a full typeglob referencing a constant subroutine,
798but using about 400 bytes less memory. This proxy constant subroutine is
799automatically upgraded to a real typeglob with subroutine if necessary.
800The approach taken is analogous to the existing space optimisation for
801subroutine stub declarations, which are stored as plain scalars in place
802of the full typeglob.
803
804Several of the core modules have been converted to use this feature for
805their system dependent constants - as a result C<use POSIX;> now takes about
806200K less memory.
807
597bb945 808=head2 C<PERL_DONT_CREATE_GVSV>
bd3831ee
RGS
809
810The new compilation flag C<PERL_DONT_CREATE_GVSV>, introduced as an option
811in perl 5.8.8, is turned on by default in perl 5.9.3. It prevents perl
812from creating an empty scalar with every new typeglob. See L<perl588delta>
813for details.
814
597bb945 815=head2 Weak references are cheaper
bd3831ee
RGS
816
817Weak reference creation is now I<O(1)> rather than I<O(n)>, courtesy of
818Nicholas Clark. Weak reference deletion remains I<O(n)>, but if deletion only
819happens at program exit, it may be skipped completely.
820
597bb945 821=head2 sort() enhancements
bd3831ee
RGS
822
823Salvador FandiƱo provided improvements to reduce the memory usage of C<sort>
824and to speed up some cases.
825
597bb945
RGS
826=head2 Memory optimisations
827
828Several internal data structures (typeglobs, GVs, CVs, formats) have been
829restructured to use less memory. (Nicholas Clark)
830
831=head2 UTF-8 cache optimisation
832
833The UTF-8 caching code is now more efficient, and used more often.
834(Nicholas Clark)
835
836=head2 Sloppy stat on Windows
837
838On Windows, perl's stat() function normally opens the file to determine
839the link count and update attributes that may have been changed through
840hard links. Setting ${^WIN32_SLOPPY_STAT} to a true value speeds up
841stat() by not performing this operation. (Jan Dubois)
842
843=back
844
845=head2 Regular expressions optimisations
846
847=over 4
848
849=item Engine de-recursivised
850
851The regular expression engine is no longer recursive, meaning that
852patterns that used to overflow the stack will either die with useful
853explanations, or run to completion, which, since they were able to blow
854the stack before, will likely take a very long time to happen. If you were
855experiencing the occasional stack overflow (or segfault) and upgrade to
856discover that now perl apparently hangs instead, look for a degenerate
857regex. (Dave Mitchell)
858
859=item Single char char-classes treated as literals
860
861Classes of a single character are now treated the same as if the character
862had been used as a literal, meaning that code that uses char-classes as an
863escaping mechanism will see a speedup. (Yves Orton)
864
865=item Trie optimisation of literal string alternations
866
867Alternations, where possible, are optimised into more efficient matching
868structures. String literal alternations are merged into a trie and are
869matched simultaneously. This means that instead of O(N) time for matching
870N alternations at a given point, the new code performs in O(1) time.
871A new special variable, ${^RE_TRIE_MAXBUF}, has been added to fine-tune
872this optimization. (Yves Orton)
873
874B<Note:> Much code exists that works around perl's historic poor
875performance on alternations. Often the tricks used to do so will disable
876the new optimisations. Hopefully the utility modules used for this purpose
877will be educated about these new optimisations by the time 5.10 is
878released.
879
880=item Aho-Corasick start-point optimisation
881
882When a pattern starts with a trie-able alternation and there aren't
883better optimisations available the regex engine will use Aho-Corasick
884matching to find the start point. (Yves Orton)
885
0eece9c0
RGS
886=back
887
cf6c151c 888=head1 Installation and Configuration Improvements
c0c97549 889
597bb945
RGS
890=head2 Configuration improvements
891
892=over 4
893
894=item C<-Dusesitecustomize>
bd3831ee 895
0eece9c0 896Run-time customization of @INC can be enabled by passing the
597bb945 897C<-Dusesitecustomize> flag to Configure. When enabled, this will make perl
0eece9c0
RGS
898run F<$sitelibexp/sitecustomize.pl> before anything else. This script can
899then be set up to add additional entries to @INC.
900
597bb945
RGS
901=item Relocatable installations
902
903There is now Configure support for creating a relocatable perl tree. If
904you Configure with C<-Duserelocatableinc>, then the paths in @INC (and
905everything else in %Config) can be optionally located via the path of the
906perl executable.
907
908That means that, if the string C<".../"> is found at the start of any
909path, it's substituted with the directory of $^X. So, the relocation can
910be configured on a per-directory basis, although the default with
911C<-Duserelocatableinc> is that everything is relocated. The initial
912install is done to the original configured prefix.
913
914=item strlcat() and strlcpy()
915
916The configuration process now detects whether strlcat() and strlcpy() are
917available. When they are not available, perl's own version is used (from
918Russ Allbery's public domain implementation). Various places in the perl
919interpreter now use them. (Steve Peters)
920
921=back
922
923=head2 Compilation improvements
924
925=over 4
926
927=item Parallel build
0eece9c0 928
bd3831ee
RGS
929Parallel makes should work properly now, although there may still be problems
930if C<make test> is instructed to run in parallel.
931
597bb945
RGS
932=item Borland's compilers support
933
bd3831ee
RGS
934Building with Borland's compilers on Win32 should work more smoothly. In
935particular Steve Hay has worked to side step many warnings emitted by their
936compilers and at least one C compiler internal error.
937
597bb945
RGS
938=item Static build on Windows
939
bd3831ee
RGS
940Perl extensions on Windows now can be statically built into the Perl DLL,
941thanks to a work by Vadim Konovalov.
942
597bb945
RGS
943=item pport.h files
944
945All F<ppport.h> files in the XS modules bundled with perl are now
946autogenerated at build time. (Marcus Holland-Moritz)
947
948=item Building XS extensions on Windows
949
950Support for building XS extension modules with the free MinGW compiler has
951been improved in the case where perl itself was built with the Microsoft
952VC++ compiler. (ActiveState)
953
954=item Support for Microsoft 64-bit compiler
955
956Support for building perl with Microsoft's 64-bit compiler has been
957improved. (ActiveState)
958
959=back
960
961=head2 Installation improvements
962
963=over 4
964
965=item Module auxiliary files
966
967README files and changelogs for CPAN modules bundled with perl are no
968longer installed.
969
970=back
971
bd3831ee
RGS
972=head2 New Or Improved Platforms
973
597bb945 974Perl has been reported to work on Symbian OS. See L<perlsymbian> for more
bd3831ee
RGS
975information.
976
597bb945
RGS
977Many improvements have been made towards making Perl work correctly on
978z/OS.
979
980Perl has been reported to work on DragonFlyBSD.
981
bd3831ee
RGS
982The VMS port has been improved. See L<perlvms>.
983
984DynaLoader::dl_unload_file() now works on Windows.
985
986Portability of Perl on various recent compilers on Windows has been
987improved (Borland C++, Visual C++ 7.0).
988
cf6c151c 989=head1 Selected Bug Fixes
c0c97549 990
bd3831ee
RGS
991=over 4
992
993=item strictures in regexp-eval blocks
994
c0c97549
RGS
995C<strict> wasn't in effect in regexp-eval blocks (C</(?{...})/>).
996
bd3831ee
RGS
997=item Calling CORE::require()
998
999CORE::require() and CORE::do() were always parsed as require() and do()
1000when they were overridden. This is now fixed.
1001
1002=item Subscripts of slices
1003
1004You can now use a non-arrowed form for chained subscripts after a list
1005slice, like in:
1006
1007 ({foo => "bar"})[0]{foo}
1008
1009This used to be a syntax error; a C<< -> >> was required.
1010
1011=item C<no warnings 'category'> works correctly with -w
1012
1013Previously when running with warnings enabled globally via C<-w>, selective
1014disabling of specific warning categories would actually turn off all warnings.
1015This is now fixed; now C<no warnings 'io';> will only turn off warnings in the
1016C<io> class. Previously it would erroneously turn off all warnings.
1017
597bb945 1018=item threads improvements
bd3831ee
RGS
1019
1020Several memory leaks in ithreads were closed. Also, ithreads were made
1021less memory-intensive.
1022
597bb945
RGS
1023C<threads> is now a dual-life module, also available on CPAN. It has been
1024expanded in many ways. A kill() method is available for thread signalling.
1025One can get thread status, or the list of running or joinable threads.
1026
1027A new C<< threads->exit() >> method is used to exit from the application
1028(this is the default for the main thread) or from the current thread only
1029(this is the default for all other threads). On the other hand, the exit()
1030built-in now always causes the whole application to terminate. (Jerry
1031D. Hedden)
1032
bd3831ee
RGS
1033=item chr() and negative values
1034
1035chr() on a negative value now gives C<\x{FFFD}>, the Unicode replacement
1036character, unless when the C<bytes> pragma is in effect, where the low
1037eight bytes of the value are used.
1038
597bb945
RGS
1039=item PERL5SHELL and tainting
1040
1041On Windows, the PERL5SHELL environment variable is now checked for
1042taintedness. (Rafael Garcia-Suarez)
1043
1044=item Using *FILE{IO}
1045
1046C<stat()> and C<-X> filetests now treat *FILE{IO} filehandles like *FILE
1047filehandles. (Steve Peters)
1048
1049=item Overloading and reblessing
1050
1051Overloading now works when references are reblessed into another class.
1052Internally, this has been implemented by moving the flag for "overloading"
1053from the reference to the referent, which logically is where it should
1054always have been. (Nicholas Clark)
1055
1056=item Overloading and UTF-8
1057
1058A few bugs related to UTF-8 handling with objects that have
1059stringification overloaded have been fixed. (Nicholas Clark)
1060
1061=item eval memory leaks fixed
1062
1063Traditionally, C<eval 'syntax error'> has leaked badly. Many (but not all)
1064of these leaks have now been eliminated or reduced. (Dave Mitchell)
1065
1066=item Random device on Windows
1067
1068In previous versions, perl would read the file F</dev/urandom> if it
1069existed when seeding its random number generator. That file is unlikely
1070to exist on Windows, and if it did would probably not contain appropriate
1071data, so perl no longer tries to read it on Windows. (Alex Davies)
1072
1073=item PERLIO_DEBUG
1074
1075The C<PERLIO_DEBUG> environment variable has no longer any effect for
1076setuid scripts and for scripts run with B<-T>.
1077
1078Moreover, with a thread-enabled perl, using C<PERLIO_DEBUG> could lead to
1079an internal buffer overflow. This has been fixed.
1080
bd3831ee 1081=back
0eece9c0 1082
cf6c151c 1083=head1 New or Changed Diagnostics
c0c97549 1084
bd3831ee
RGS
1085=over 4
1086
1087=item Deprecated use of my() in false conditional
1088
c0c97549
RGS
1089A new deprecation warning, I<Deprecated use of my() in false conditional>,
1090has been added, to warn against the use of the dubious and deprecated
1091construct
1092
1093 my $x if 0;
1094
1095See L<perldiag>. Use C<state> variables instead.
1096
bd3831ee
RGS
1097=item !=~ should be !~
1098
0eece9c0
RGS
1099A new warning, C<!=~ should be !~>, is emitted to prevent this misspelling
1100of the non-matching operator.
1101
bd3831ee
RGS
1102=item Newline in left-justified string
1103
0eece9c0
RGS
1104The warning I<Newline in left-justified string> has been removed.
1105
bd3831ee
RGS
1106=item Too late for "-T" option
1107
0eece9c0
RGS
1108The error I<Too late for "-T" option> has been reformulated to be more
1109descriptive.
1110
bd3831ee
RGS
1111=item "%s" variable %s masks earlier declaration
1112
1113This warning is now emitted in more consistent cases; in short, when one
1114of the declarations involved is a C<my> variable:
1115
1116 my $x; my $x; # warns
1117 my $x; our $x; # warns
1118 our $x; my $x; # warns
1119
1120On the other hand, the following:
1121
1122 our $x; our $x;
1123
1124now gives a C<"our" variable %s redeclared> warning.
1125
1126=item readdir()/closedir()/etc. attempted on invalid dirhandle
1127
1128These new warnings are now emitted when a dirhandle is used but is
1129either closed or not really a dirhandle.
1130
1131=item perl -V
1132
0eece9c0
RGS
1133C<perl -V> has several improvements, making it more useable from shell
1134scripts to get the value of configuration variables. See L<perlrun> for
1135details.
1136
bd3831ee
RGS
1137=back
1138
cf6c151c 1139=head1 Changed Internals
c0c97549 1140
bd3831ee
RGS
1141In general, the source code of perl has been refactored, tied up, and
1142optimized in many places. Also, memory management and allocation has been
1143improved in a couple of points.
1144
c0c97549
RGS
1145=head2 Reordering of SVt_* constants
1146
1147The relative ordering of constants that define the various types of C<SV>
1148have changed; in particular, C<SVt_PVGV> has been moved before C<SVt_PVLV>,
1149C<SVt_PVAV>, C<SVt_PVHV> and C<SVt_PVCV>. This is unlikely to make any
1150difference unless you have code that explicitly makes assumptions about that
1151ordering. (The inheritance hierarchy of C<B::*> objects has been changed
1152to reflect this.)
1153
1154=head2 Removal of CPP symbols
1155
1156The C preprocessor symbols C<PERL_PM_APIVERSION> and
1157C<PERL_XS_APIVERSION>, which were supposed to give the version number of
1158the oldest perl binary-compatible (resp. source-compatible) with the
1159present one, were not used, and sometimes had misleading values. They have
1160been removed.
1161
1162=head2 Less space is used by ops
1163
1164The C<BASEOP> structure now uses less space. The C<op_seq> field has been
1165removed and replaced by the one-bit fields C<op_opt>. C<op_type> is now 9
1166bits long. (Consequently, the C<B::OP> class doesn't provide an C<seq>
1167method anymore.)
1168
1169=head2 New parser
1170
1171perl's parser is now generated by bison (it used to be generated by
1172byacc.) As a result, it seems to be a bit more robust.
1173
bd3831ee
RGS
1174Also, Dave Mitchell improved the lexer debugging output under C<-DT>.
1175
1176=head2 Use of C<const>
1177
1178Andy Lester supplied many improvements to determine which function
1179parameters and local variables could actually be declared C<const> to the C
1180compiler. Steve Peters provided new C<*_set> macros and reworked the core to
1181use these rather than assigning to macros in LVALUE context.
1182
1183=head2 Mathoms
1184
1185A new file, F<mathoms.c>, has been added. It contains functions that are
1186no longer used in the perl core, but that remain available for binary or
1187source compatibility reasons. However, those functions will not be
1188compiled in if you add C<-DNO_MATHOMS> in the compiler flags.
1189
1190=head2 C<AvFLAGS> has been removed
1191
1192The C<AvFLAGS> macro has been removed.
1193
1194=head2 C<av_*> changes
1195
1196The C<av_*()> functions, used to manipulate arrays, no longer accept null
1197C<AV*> parameters.
1198
597bb945
RGS
1199=head2 $^H and %^H
1200
1201The implementation of the special variables $^H and %^H has changed, to
1202allow implementing lexical pragmas in pure perl.
1203
bd3831ee
RGS
1204=head2 B:: modules inheritance changed
1205
1206The inheritance hierarchy of C<B::> modules has changed; C<B::NV> now
1207inherits from C<B::SV> (it used to inherit from C<B::IV>).
1208
cf6c151c 1209=head1 New Tests
c0c97549 1210
cf6c151c 1211=head1 Known Problems
c0c97549
RGS
1212
1213There's still a remaining problem in the implementation of the lexical
1214C<$_>: it doesn't work inside C</(?{...})/> blocks. (See the TODO test in
1215F<t/op/mydef.t>.)
1216
cf6c151c 1217=head1 Platform Specific Problems
c0c97549 1218
cf6c151c
RGS
1219=head1 Reporting Bugs
1220
1221=head1 SEE ALSO
1222
1223The F<Changes> file and the perl590delta to perl595delta man pages for
1224exhaustive details on what changed.
1225
1226The F<INSTALL> file for how to build Perl.
1227
1228The F<README> file for general stuff.
1229
1230The F<Artistic> and F<Copying> files for copyright information.
1231
1232=cut