* fix a perlop fix from debian: http://bugs.debian.org/514814
[p5sagit/p5-mst-13.2.git] / pod / perl591delta.pod
CommitLineData
1400179b 1=head1 NAME
2
70693193 3perl591delta - what is new for perl v5.9.1
1400179b 4
5=head1 DESCRIPTION
6
f15752a5 7This document describes differences between the 5.9.0 and the 5.9.1
fa11829f 8development releases. See L<perl590delta> for the differences between
9b11ae5e 95.8.0 and 5.9.0.
1400179b 10
11=head1 Incompatible Changes
12
3c1c0f69 13=head2 substr() lvalues are no longer fixed-length
14
15The lvalues returned by the three argument form of substr() used to be a
16"fixed length window" on the original string. In some cases this could
17cause surprising action at distance or other undefined behaviour. Now the
fa11829f 18length of the window adjusts itself to the length of the string assigned to
3c1c0f69 19it.
20
21=head2 The C<:unique> attribute is only meaningful for globals
22
23Now applying C<:unique> to lexical variables and to subroutines will
24result in a compilation error.
25
1400179b 26=head1 Core Enhancements
27
59f00321 28=head2 Lexical C<$_>
29
30The default variable C<$_> can now be lexicalized, by declaring it like
31any other lexical variable, with a simple
32
33 my $_;
34
35The operations that default on C<$_> will use the lexically-scoped
36version of C<$_> when it exists, instead of the global C<$_>.
37
38In a C<map> or a C<grep> block, if C<$_> was previously my'ed, then the
39C<$_> inside the block is lexical as well (and scoped to the block).
40
41In a scope where C<$_> has been lexicalized, you can still have access to
42the global version of C<$_> by using C<$::_>, or, more simply, by
43overriding the lexical declaration with C<our $_>.
44
1400179b 45=head2 Tied hashes in scalar context
46
f99d9048 47As of perl 5.8.2/5.9.0, tied hashes did not return anything useful in
48scalar context, for example when used as boolean tests:
1400179b 49
50 if (%tied_hash) { ... }
51
52The old nonsensical behaviour was always to return false,
53regardless of whether the hash is empty or has elements.
54
55There is now an interface for the implementors of tied hashes to implement
56the behaviour of a hash in scalar context, via the SCALAR method (see
57L<perltie>). Without a SCALAR method, perl will try to guess whether
58the hash is empty, by testing if it's inside an iteration (in this case
59it can't be empty) or by calling FIRSTKEY.
60
f0f92e3c 61=head2 Formats
62
63Formats were improved in several ways. A new field, C<^*>, can be used for
64variable-width, one-line-at-a-time text. Null characters are now handled
65correctly in picture lines. Using C<@#> and C<~~> together will now
66produce a compile-time error, as those format fields are incompatible.
67L<perlform> has been improved, and miscellaneous bugs fixed.
68
fbb0b3b3 69=head2 Stacked filetest operators
70
71As a new form of syntactic sugar, it's now possible to stack up filetest
72operators. You can now write C<-f -w -x $file> in a row to mean
73C<-x $file && -w _ && -f _>. See L<perlfunc/-X>.
74
1400179b 75=head1 Modules and Pragmata
76
f0f92e3c 77=over 4
78
a1686c72 79=item Benchmark
80
81In C<Benchmark>, cmpthese() and timestr() now use the time statistics of
82children instead of parent when the selected style is 'nop'.
83
f0f92e3c 84=item Carp
85
86The error messages produced by C<Carp> now include spaces between the
87arguments in function argument lists: this makes long error messages
88appear more nicely in browsers and other tools.
89
90=item Exporter
91
92C<Exporter> will now recognize grouping tags (such as C<:name>) anywhere
93in the import list, not only at the beginning.
94
95=item FindBin
96
97A function C<again> is provided to resolve problems where modules in different
98directories wish to use FindBin.
99
100=item List::Util
101
102You can now weaken references to read only values.
103
104=item threads::shared
105
106C<cond_wait> has a new two argument form. C<cond_timedwait> has been added.
107
108=back
109
1400179b 110=head1 Utility Changes
111
112C<find2perl> now assumes C<-print> as a default action. Previously, it
113needed to be specified explicitly.
114
f0f92e3c 115A new utility, C<prove>, makes it easy to run an individual regression test
116at the command line. C<prove> is part of Test::Harness, which users of earlier
117Perl versions can install from CPAN.
118
466126d3 119The perl debugger now supports a C<save> command, to save the current
120history to a file, and an C<i> command, which prints the inheritance tree
121of its argument (if the C<Class::ISA> module is installed.)
122
f0f92e3c 123=head1 Documentation
124
125The documentation has been revised in places to produce more standard manpages.
126
127The long-existing feature of C</(?{...})/> regexps setting C<$_> and pos()
128is now documented.
1400179b 129
f99d9048 130=head1 Performance Enhancements
131
3c1c0f69 132Sorting arrays in place (C<@a = sort @a>) is now optimized to avoid
133making a temporary copy of the array.
134
466126d3 135The operations involving case mapping on UTF-8 strings (uc(), lc(),
136C<//i>, etc.) have been greatly speeded up.
137
3c1c0f69 138Access to elements of lexical arrays via a numeric constant between 0 and
139255 is now faster. (This used to be only the case for global arrays.)
1400179b 140
141=head1 Selected Bug Fixes
142
3c1c0f69 143=head2 UTF-8 bugs
f0f92e3c 144
3c1c0f69 145Using substr() on a UTF-8 string could cause subsequent accesses on that
146string to return garbage. This was due to incorrect UTF-8 offsets being
f0f92e3c 147cached, and is now fixed.
148
149join() could return garbage when the same join() statement was used to
3c1c0f69 150process 8 bit data having earlier processed UTF-8 data, due to the flags
f0f92e3c 151on that statement's temporary workspace not being reset correctly. This
152is now fixed.
153
154Using Unicode keys with tied hashes should now work correctly.
155
3c1c0f69 156chop() and chomp() used to mangle UTF-8 strings. This has been fixed.
157
158sprintf() used to misbehave when the format string was in UTF-8. This is
159now fixed.
f0f92e3c 160
161=head2 Threading bugs
162
163Hashes with the C<:unique> attribute weren't made read-only in new
164threads. They are now.
165
166=head2 More bugs
167
3c1c0f69 168C<$a .. $b> will now work as expected when either $a or $b is C<undef>.
f0f92e3c 169
170Reading $^E now preserves $!. Previously, the C code implementing $^E
171did not preserve C<errno>, so reading $^E could cause C<errno> and therefore
172C<$!> to change unexpectedly.
173
31a10c70 174C<strict> wasn't in effect in regexp-eval blocks (C</(?{...})/>).
f0f92e3c 175
1400179b 176=head1 New or Changed Diagnostics
177
466126d3 178A new deprecation warning, I<Deprecated use of my() in false conditional>,
179has been added, to warn against the use of the dubious and deprecated
180construct
181
182 my $x if 0;
183
184See L<perldiag>.
185
3c1c0f69 186The fatal error I<DESTROY created new reference to dead object> is now
f0f92e3c 187documented in L<perldiag>.
188
3c1c0f69 189A new error, I<%ENV is aliased to %s>, is produced when taint checks are
190enabled and when C<*ENV> has been aliased (and thus doesn't reflect the
f0f92e3c 191program's environment anymore.)
192
1400179b 193=head1 Changed Internals
194
9b11ae5e 195These news matter to you only if you either write XS code or like to
196know about or hack Perl internals (using Devel::Peek or any of the
197C<B::> modules counts), or like to run Perl with the C<-D> option.
198
199=head2 Reordering of SVt_* constants
200
201The relative ordering of constants that define the various types of C<SV>
fa46452e 202have changed; in particular, C<SVt_PVGV> has been moved before C<SVt_PVLV>,
9b11ae5e 203C<SVt_PVAV>, C<SVt_PVHV> and C<SVt_PVCV>. This is unlikely to make any
204difference unless you have code that explicitly makes assumptions about that
205ordering. (The inheritance hierarchy of C<B::*> objects has been changed
206to reflect this.)
207
a5dbb3ac 208=head2 Removal of CPP symbols
209
210The C preprocessor symbols C<PERL_PM_APIVERSION> and
211C<PERL_XS_APIVERSION>, which were supposed to give the version number of
212the oldest perl binary-compatible (resp. source-compatible) with the
213present one, were not used, and sometimes had misleading values. They have
214been removed.
215
265db0e6 216=head2 Less space is used by ops
217
218The C<BASEOP> structure now uses less space. The C<op_seq> field has been
219removed and replaced by two one-bit fields, C<op_opt> and C<op_static>.
220C<opt_type> is now 9 bits long. (Consequently, the C<B::OP> class doesn't
221provide an C<seq> method anymore.)
222
3c1c0f69 223=head2 New parser
224
225perl's parser is now generated by bison (it used to be generated by
226byacc.) As a result, it seems to be a bit more robust.
227
f0f92e3c 228=head1 Configuration and Building
229
230C<Configure> now invokes callbacks regardless of the value of the variable
231they are called for. Previously callbacks were only invoked in the
232C<case $variable $define)> branch. This change should only affect platform
233maintainers writing configuration hints files.
234
f15752a5 235The portability and cleanliness of the Win32 makefiles has been improved.
1400179b 236
237=head1 Known Problems
238
3c1c0f69 239There are still a couple of problems in the implementation of the lexical
240C<$_>: it doesn't work inside C</(?{...})/> blocks and with regard to the
241reverse() built-in used without arguments. (See the TODO tests in
242F<t/op/mydef.t>.)
243
244=head2 Platform Specific Problems
245
246The test F<ext/IPC/SysV/t/ipcsysv.t> may fail on OpenBSD. This hasn't been
247diagnosed yet.
248
249On some configurations on AIX 5, one test in F<lib/Time/Local.t> fails.
250When configured with long doubles, perl may fail tests 224-236 in
251F<t/op/pow.t> on the same platform.
252
1bafd7b3 253For threaded builds, F<ext/threads/shared/t/wait.t> has been reported to
254fail some tests on HP-UX 10.20.
255
3c1c0f69 256=head1 To-do for perl 5.10.0
257
258This is a non-exhaustive, non-ordered, non-contractual and non-definitive
259list of things to do (or nice to have) for perl 5.10.0 :
260
261Clean up and finish support for assertions. See L<assertions>.
262
263Reimplement the mechanism of lexical pragmas to be more extensible. Fix
f15752a5 264current pragmas that don't work well (or at all) with lexical scopes or in
265run-time eval(STRING) (C<sort>, C<re>, C<encoding> for example). MJD has a
266preliminary patch that implements this.
f99d9048 267
268Fix (or rewrite) the implementation of the C</(?{...})/> closures.
3c1c0f69 269
270Conversions from byte strings to UTF-8 currently map high bit characters
271to Unicode without translation (or, depending on how you look at it, by
f15752a5 272implicitly assuming that the byte strings are in Latin-1). As perl assumes
273the C locale by default, upgrading a string to UTF-8 may change the
274meaning of its contents regarding character classes, case mapping, etc.
275This should probably emit a warning (at least).
3c1c0f69 276
277Introduce a new special block, UNITCHECK, which is run at the end of a
278compilation unit (module, file, eval(STRING) block). This will correspond to
279the Perl 6 CHECK. Perl 5's CHECK cannot be changed or removed because the
f99d9048 280O.pm/B.pm backend framework depends on it.
3c1c0f69 281
282Study the possibility of adding a new prototype character, C<_>, meaning
283"this argument defaults to $_".
284
285Make the peephole optimizer optional.
286
287Allow lexical aliases (maybe via the syntax C<my \$alias = \$foo>.
288
289Fix the bugs revealed by running the test suite with the C<-t> switch (via
290C<make test.taintwarn>).
291
292Make threads more robust.
293
1bafd7b3 294Make C<no 6> and C<no v6> work (opposite of C<use 5.005>, etc.).
3c1c0f69 295
296A test suite for the B module would be nice.
297
298A ponie.
1400179b 299
300=head1 Reporting Bugs
301
302If you find what you think is a bug, you might check the articles
303recently posted to the comp.lang.perl.misc newsgroup and the perl
304bug database at http://bugs.perl.org/ . There may also be
f15752a5 305information at http://www.perl.org/ , the Perl Home Page.
1400179b 306
307If you believe you have an unreported bug, please run the B<perlbug>
308program included with your release. Be sure to trim your bug down
309to a tiny but sufficient test case. Your bug report, along with the
310output of C<perl -V>, will be sent off to perlbug@perl.org to be
311analysed by the Perl porting team.
312
313=head1 SEE ALSO
314
315The F<Changes> file for exhaustive details on what changed.
316
317The F<INSTALL> file for how to build Perl.
318
319The F<README> file for general stuff.
320
321The F<Artistic> and F<Copying> files for copyright information.
322
323=cut