More perldelta entries and fixes
[p5sagit/p5-mst-13.2.git] / pod / perl594delta.pod
CommitLineData
6c7deadb 1=head1 NAME
2
3perldelta - what is new for perl v5.9.4
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.9.3 and the 5.9.4
8developement releases. See L<perl590delta>, L<perl591delta>, L<perl592delta>
9and L<perl593delta> for the differences between 5.8.0 and 5.9.3.
10
11=head1 Incompatible Changes
12
4db748fd 13=head2 chdir FOO
14
473aa102 15A bareword argument to chdir() is now recognized as a file handle.
4db748fd 16Earlier releases interpreted the bareword as a directory name.
21a732f3 17(Gisle Aas)
4db748fd 18
ddc61b51 19=head2 Handling of pmc files
20
b7d91234 21An old feature of perl was that before C<require> or C<use> look for a
473aa102 22file with a F<.pm> extension, they will first look for a similar filename
23with a F<.pmc> extension. If this file is found, it will be loaded in
24place of any potentially existing file ending in a F<.pm> extension.
ddc61b51 25
473aa102 26Previously, F<.pmc> files were loaded only if more recent than the
27matching F<.pm> file. Starting with 5.9.4, they'll be always loaded if
28they exist. (This trick is used by Pugs.)
ddc61b51 29
30=head2 @- and @+ in patterns
31
32The special arrays C<@-> and C<@+> are no longer interpolated in regular
21a732f3 33expressions. (Sadahiro Tomoyuki)
ddc61b51 34
5d121f7f 35=head2 $AUTOLOAD can now be tainted
36
37If you call a subroutine by a tainted name, and if it defers to an
38AUTOLOAD function, then $AUTOLOAD will be (correctly) tainted.
21a732f3 39(Rick Delaney)
5d121f7f 40
6c7deadb 41=head1 Core Enhancements
42
6c20a8f9 43=head2 state() variables
44
3c1cb5e0 45A new class of variables has been introduced. State variables are similar
46to C<my> variables, but are declared with the C<state> keyword in place of
47C<my>. They're visible only in their lexical scope, but their value in
48persistent: unlike C<my> variables, they're not undefined at scope entry,
21a732f3 49and retain their previous value. (Rafael Garcia-Suarez)
3c1cb5e0 50
51To use state variables, one needs to enable them by using
52
53 use feature "state";
54
55or by using the C<-E> command-line switch in one-liners.
56
57See L<perlsub/"Persistent variables via state()">.
58
d06a6528 59=head2 UNIVERSAL::DOES()
ddc61b51 60
3c1cb5e0 61The C<UNIVERSAL> class has a new method, C<DOES()>. It has been added to
62solve semantic problems with the C<isa()> method. C<isa()> checks for
63inheritance, while C<DOES()> has been designed to be overriden when
64module authors use other types of relations between classes (in addition
21a732f3 65to inheritance). (chromatic)
3c1cb5e0 66
67See L<< UNIVERSAL/"$obj->DOES( ROLE )" >>.
68
21a732f3 69=head2 Exceptions in constant folding
70
71The constant folding routine is now wrapped in an exception handler, and
72if folding throws an exception (such as attempting to evaluate 0/0), perl
73now retains the current optree, rather than aborting the whole program.
b7d91234 74(Nicholas Clark, Dave Mitchell)
75
76=head2 Source filters in @INC
77
78It's possible to enhance the mechanism of subroutine hooks in @INC by
79adding a source filter on top of the filehandle opened and returned by the
80hook. This feature was planned a long time ago, but wasn't quite working
81until now. See L<perlfunc/require> for details. (Nicholas Clark)
82
83=head2 MAD
84
85MAD, which stands for I<Misc Attribute Decoration>, is a
86still-in-development work leading to a Perl 5 to Perl 6 convertor. To
87enable it, it's necessary to pass the argument C<-Dmad> to Configure. The
88obtained perl isn't binary compatible with a regular perl 5.9.4, and has
89space and speed penalties; moreover not all regression tests still pass
90with it. (Larry Wall, Nicholas Clark)
21a732f3 91
6c7deadb 92=head1 Modules and Pragmata
93
b7d91234 94=over 4
95
96=item *
97
473aa102 98C<encoding::warnings> is now a lexical pragma. (Although on older perls,
99which don't have support for lexical pragmas, it keeps its global
21a732f3 100behaviour.) (Audrey Tang)
6c20a8f9 101
b7d91234 102=item *
103
104C<threads> is now a dual-life module, also available on CPAN. It has been
105expanded in many ways. A kill() method is available for thread signalling.
106One can get thread status, or the list of running or joinable threads.
107
108A new C<< threads->exit() >> method is used to exit from the application
109(this is the default for the main thread) or from the current thread only
110(this is the default for all other threads). On the other hand, the exit()
111built-in now always causes the whole application to terminate. (Jerry
112D. Hedden)
113
114=back
ddc61b51 115
6c20a8f9 116=head2 New Core Modules
117
118=over 4
119
120=item *
121
21a732f3 122C<Hash::Util::FieldHash>, by Anno Siegel, has been added. This module
123provides support for I<field hashes>: hashes that maintain an association
124of a reference with a value, in a thread-safe garbage-collected way.
ecf6cde6 125
126=item *
127
21a732f3 128C<Module::Build>, by Ken Williams, has been added. It's an alternative to
473aa102 129C<ExtUtils::MakeMaker> to build and install perl modules.
130
131=item *
132
b7d91234 133C<Module::Load>, by Jos Boumans, has been added. It provides a single
134interface to load Perl modules and F<.pl> files.
6c20a8f9 135
136=item *
137
21a732f3 138C<Module::Loaded>, by Jos Boumans, has been added. It's used to mark
139modules as loaded or unloaded.
6c20a8f9 140
141=item *
142
21a732f3 143C<Package::Constants>, by Jos Boumans, has been added. It's a simple
144helper to list all constants declared in a given package.
6c20a8f9 145
d06a6528 146=item *
147
21a732f3 148C<Win32API::File>, by Tye McQueen, has been added (for Windows builds).
149This module provides low-level access to Win32 system API calls for
150files/dirs.
d06a6528 151
6c20a8f9 152=back
153
6c7deadb 154=head1 Utility Changes
155
3c1cb5e0 156=head2 config_data
157
158C<config_data> is a new utility that comes with C<Module::Build>. It
159provides a command-line interface to the configuration of Perl modules
160that use Module::Build's framework of configurability (that is,
161C<*::ConfigData> modules, that contain local configuration information for
162their parent modules.)
163
6c7deadb 164=head1 Documentation
165
6c20a8f9 166=head2 New manpage, perlpragma
167
473aa102 168The L<perlpragma> manpage documents how to write one's own lexical
36d7017e 169pragmas in pure Perl (something that is possible only starting with
1705.9.4).
473aa102 171
6c20a8f9 172=head2 New manpage, perlreguts
173
473aa102 174The L<perlreguts> manpage, due to Yves Orton, describes internals of the
175Perl regular expression engine.
176
6c20a8f9 177=head2 New manpage, perlunitut
178
473aa102 179The L<perlunitut> manpage is an tutorial for programming with Unicode and
180string encodings in Perl, due to Juerd Waalboer.
181
6c7deadb 182=head1 Performance Enhancements
183
ffb08095 184=head2 Memory optimisations
185
21a732f3 186Several internal data structures (typeglobs, GVs, CVs, formats) have been
187restructured to use less memory. (Nicholas Clark)
188
ffb08095 189=head2 UTF-8 cache optimisation
190
21a732f3 191The UTF-8 caching code is now more efficient, and used more often.
192(Nicholas Clark)
193
ffb08095 194=head2 Regular expressions
195
196=over 4
197
198=item Engine de-recursiveized
199
200The regular expression engine is no longer recursive, meaning that
201patterns that used to overflow the stack will either die with useful
202explanations, or run to completion, which, since they were able to blow
203the stack before, will likely take a very long time to happen. If you were
204experiencing the occasional stack overflow (or segfault) and upgrade to
205discover that now perl apparently hangs instead, look for a degenerate
b7d91234 206regex. (Dave Mitchell)
ffb08095 207
208=item Single char char-classes treated as literals
209
b7d91234 210Classes of a single character are now treated the same as if the character
211had been used as a literal, meaning that code that uses char-classes as an
212escaping mechanism will see a speedup. (Yves Orton)
ffb08095 213
214=item Trie optimisation of literal string alternations
215
216Alternations, where possible, are optimised into more efficient matching
217structures. String literal alternations are merged into a trie and are
218matched simultaneously. This means that instead of O(N) time for matching
b7d91234 219N alternations at a given point the new code performs in O(1) time. (Yves
220Orton)
ffb08095 221
222B<Note:> Much code exists that works around perl's historic poor
223performance on alternations. Often the tricks used to do so will disable
224the new optimisations. Hopefully the utility modules used for this purpose
225will be educated about these new optimisations by the time 5.10 is
226released.
227
228=item Aho-Corasick start-point optimisation
229
230When a pattern starts with a trie-able alternation and there aren't
231better optimisations available the regex engine will use Aho-Corasick
b7d91234 232matching to find the start point. (Yves Orton)
ffb08095 233
234=back
6c20a8f9 235
6c7deadb 236=head1 Installation and Configuration Improvements
237
21a732f3 238=head2 Relocatable installations
239
b7d91234 240There is now Configure support for creating a relocatable perl tree. If
241you Configure with C<-Duserelocatableinc>, then the paths in @INC (and
242everything else in %Config) can be optionally located via the path of the
243perl executable.
244
245That means that, if the string C<".../"> is found at the start of any
246path, it's substituted with the directory of $^X. So, the relocation can
247be configured on a per-directory basis, although the default with
248C<-Duserelocatableinc> is that everything is relocated. The initial
249install is done to the original configured prefix.
21a732f3 250
ddc61b51 251=head2 Ports
252
473aa102 253Many improvements have been made towards making Perl work correctly on
254z/OS.
255
3c1cb5e0 256Perl has been reported to work on DragonFlyBSD.
257
ddc61b51 258=head2 Compilation improvements
259
260All F<ppport.h> files in the XS modules bundled with perl are now
21a732f3 261autogenerated at build time. (Marcus Holland-Moritz)
ddc61b51 262
263=head2 New probes
264
3c1cb5e0 265The configuration process now detects whether strlcat() and strlcpy() are
ddc61b51 266available. When they are not available, perl's own version is used (from
267Russ Allbery's public domain implementation). Various places in the perl
21a732f3 268interpreter now uses them. (Steve Peters)
ddc61b51 269
6c7deadb 270=head1 Selected Bug Fixes
271
473aa102 272=head2 PERL5SHELL and tainting
273
21a732f3 274On Windows, PERL5SHELL is now checked for taintedness. (Rafael
275Garcia-Suarez)
473aa102 276
277=head2 Using *FILE{IO}
278
279C<stat()> and C<-X> filetests now treat *FILE{IO} filehandles like *FILE
21a732f3 280filehandles. (Steve Peters)
281
282=head2 Overloading and reblessing
283
284Overloading now works when references are reblessed into another class.
285Internally, this has been implemented by moving the flag for "overloading"
286from the reference to the referent, which logically is where it should
287always have been. (Nicholas Clark)
288
289=head2 Overloading and UTF-8
290
291A few bugs related to UTF-8 handling with objects that have
292stringification overloaded have been fixed. (Nicholas Clark)
473aa102 293
6c7deadb 294=head1 New or Changed Diagnostics
295
21a732f3 296=over 4
297
298=item State variable %s will be reinitialized
299
300One can assign initial values to state variables, but not when they're
301declared as a sub-part of a list assignment. See L<perldiag>.
302
303=back
304
6c7deadb 305=head1 Changed Internals
306
3c1cb5e0 307A new file, F<mathoms.c>, contains functions that aren't used anymore in
308the perl core, but that remain around because modules out there might
309still use them. They come from a factorization effort: for example, many
310PP functions are now shared for several ops.
6c20a8f9 311
b7d91234 312The implementation of the special variables $^H and %^H has changed, to
313allow implementing lexical pragmas in pure perl.
314
6c7deadb 315=head1 Known Problems
316
3c1cb5e0 317One warning test (number 263 in F<lib/warnings.t>) fails under UTF-8
318locales.
319
b7d91234 320Bytecode tests fails under several platforms. We are considering removing
321support for byteloader and compiler before the 5.10.0 release.
6c7deadb 322
d06a6528 323=head2 Platform-specific Problems
324
325The test F<ext/Socket/t/socketpair.t> crashes after completing all tests
326successfully when built with USE_ITHREADS and PERL_IMPLICIT_SYS on Win32.
327
6c7deadb 328=head1 Reporting Bugs
329
330If you find what you think is a bug, you might check the articles
331recently posted to the comp.lang.perl.misc newsgroup and the perl
36d7017e 332bug database at http://rt.perl.org/rt3/ . There may also be
6c7deadb 333information at http://www.perl.org/ , the Perl Home Page.
334
335If you believe you have an unreported bug, please run the B<perlbug>
336program included with your release. Be sure to trim your bug down
337to a tiny but sufficient test case. Your bug report, along with the
338output of C<perl -V>, will be sent off to perlbug@perl.org to be
339analysed by the Perl porting team.
340
341=head1 SEE ALSO
342
343The F<Changes> file for exhaustive details on what changed.
344
345The F<INSTALL> file for how to build Perl.
346
347The F<README> file for general stuff.
348
349The F<Artistic> and F<Copying> files for copyright information.
350
351=cut