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