3 perldelta - what is new for perl v5.9.1
7 This document describes differences between the 5.9.0 release and
8 the 5.9.1 release. 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 iself 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, tied hashes did not return anything useful in scalar
48 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 Sorting arrays in place (C<@a = sort @a>) is now optimized to avoid
131 making a temporary copy of the array.
133 =head1 Performance Enhancements
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 Reentrant functions will (once more) work with C++. 5.8.2 introduced a bugfix
175 which accidentally broke the compilation of Perl extensions written in C++.
177 C<strict> wasn't in effect in regexp-eval blocks (C</(?{...})/>).
179 =head1 New or Changed Diagnostics
181 A new deprecation warning, I<Deprecated use of my() in false conditional>,
182 has been added, to warn against the use of the dubious and deprecated
189 The fatal error I<DESTROY created new reference to dead object> is now
190 documented in L<perldiag>.
192 A new error, I<%ENV is aliased to %s>, is produced when taint checks are
193 enabled and when C<*ENV> has been aliased (and thus doesn't reflect the
194 program's environment anymore.)
196 =head1 Changed Internals
198 These news matter to you only if you either write XS code or like to
199 know about or hack Perl internals (using Devel::Peek or any of the
200 C<B::> modules counts), or like to run Perl with the C<-D> option.
202 =head2 Reordering of SVt_* constants
204 The relative ordering of constants that define the various types of C<SV>
205 have changed; in particular, C<SVt_PVGV> has been moved before C<SVt_PVLV>,
206 C<SVt_PVAV>, C<SVt_PVHV> and C<SVt_PVCV>. This is unlikely to make any
207 difference unless you have code that explicitly makes assumptions about that
208 ordering. (The inheritance hierarchy of C<B::*> objects has been changed
211 =head2 Removal of CPP symbols
213 The C preprocessor symbols C<PERL_PM_APIVERSION> and
214 C<PERL_XS_APIVERSION>, which were supposed to give the version number of
215 the oldest perl binary-compatible (resp. source-compatible) with the
216 present one, were not used, and sometimes had misleading values. They have
219 =head2 Less space is used by ops
221 The C<BASEOP> structure now uses less space. The C<op_seq> field has been
222 removed and replaced by two one-bit fields, C<op_opt> and C<op_static>.
223 C<opt_type> is now 9 bits long. (Consequently, the C<B::OP> class doesn't
224 provide an C<seq> method anymore.)
228 perl's parser is now generated by bison (it used to be generated by
229 byacc.) As a result, it seems to be a bit more robust.
231 =head1 Configuration and Building
233 C<Configure> now invokes callbacks regardless of the value of the variable
234 they are called for. Previously callbacks were only invoked in the
235 C<case $variable $define)> branch. This change should only affect platform
236 maintainers writing configuration hints files.
238 The portability and clealiness of the Win32 makefiles has been improved.
240 =head1 Known Problems
242 There are still a couple of problems in the implementation of the lexical
243 C<$_>: it doesn't work inside C</(?{...})/> blocks and with regard to the
244 reverse() built-in used without arguments. (See the TODO tests in
247 =head2 Platform Specific Problems
249 The test F<ext/IPC/SysV/t/ipcsysv.t> may fail on OpenBSD. This hasn't been
252 On some configurations on AIX 5, one test in F<lib/Time/Local.t> fails.
253 When configured with long doubles, perl may fail tests 224-236 in
254 F<t/op/pow.t> on the same platform.
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 with lexical scopes (C<sort>, for
265 example). MJD has ideas on this.
267 Conversions from byte strings to UTF-8 currently map high bit characters
268 to Unicode without translation (or, depending on how you look at it, by
269 implicitly assuming the byte strings are in Latin-1). This is wrong,
270 because perl assumes the C locale by default. Thus upgrading a string to
271 UTF-8 (esp. in place) may change the meaning of its contents regarding
272 character classes, case mapping, etc. Try to find a way to fix it without
273 breaking all the legacy code out there (and without making the life of the
274 XS coders miserable.)
276 Introduce a new special block, UNITCHECK, which is run at the end of a
277 compilation unit (module, file, eval(STRING) block). This will correspond to
278 the Perl 6 CHECK. Perl 5's CHECK cannot be changed or removed because the
279 O/B framework depends on it.
281 Study the possibility of adding a new prototype character, C<_>, meaning
282 "this argument defaults to $_".
284 Make the peephole optimizer optional.
286 Allow lexical aliases (maybe via the syntax C<my \$alias = \$foo>.
288 Fix the bugs revealed by running the test suite with the C<-t> switch (via
289 C<make test.taintwarn>).
291 Make threads more robust.
293 Make C<no 6> and C<no v6> work.
295 A test suite for the B module would be nice.
299 =head1 Reporting Bugs
301 If you find what you think is a bug, you might check the articles
302 recently posted to the comp.lang.perl.misc newsgroup and the perl
303 bug database at http://bugs.perl.org/ . There may also be
304 information at http://www.perl.com/ , the Perl Home Page.
306 If you believe you have an unreported bug, please run the B<perlbug>
307 program included with your release. Be sure to trim your bug down
308 to a tiny but sufficient test case. Your bug report, along with the
309 output of C<perl -V>, will be sent off to perlbug@perl.org to be
310 analysed by the Perl porting team.
314 The F<Changes> file for exhaustive details on what changed.
316 The F<INSTALL> file for how to build Perl.
318 The F<README> file for general stuff.
320 The F<Artistic> and F<Copying> files for copyright information.