source: trunk/essentials/dev-lang/perl/pod/perl581delta.pod

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 37.2 KB
Line 
1=head1 NAME
2
3perl581delta - what is new for perl v5.8.1
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.8.0 release and
8the 5.8.1 release.
9
10If you are upgrading from an earlier release such as 5.6.1, first read
11the L<perl58delta>, which describes differences between 5.6.0 and
125.8.0.
13
14In case you are wondering about 5.6.1, it was bug-fix-wise rather
15identical to the development release 5.7.1. Confused? This timeline
16hopefully helps a bit: it lists the new major releases, their maintenance
17releases, and the development releases.
18
19 New Maintenance Development
20
21 5.6.0 2000-Mar-22
22 5.7.0 2000-Sep-02
23 5.6.1 2001-Apr-08
24 5.7.1 2001-Apr-09
25 5.7.2 2001-Jul-13
26 5.7.3 2002-Mar-05
27 5.8.0 2002-Jul-18
28 5.8.1 2003-Sep-25
29
30=head1 Incompatible Changes
31
32=head2 Hash Randomisation
33
34Mainly due to security reasons, the "random ordering" of hashes
35has been made even more random. Previously while the order of hash
36elements from keys(), values(), and each() was essentially random,
37it was still repeatable. Now, however, the order varies between
38different runs of Perl.
39
40B<Perl has never guaranteed any ordering of the hash keys>, and the
41ordering has already changed several times during the lifetime of
42Perl 5. Also, the ordering of hash keys has always been, and
43continues to be, affected by the insertion order.
44
45The added randomness may affect applications.
46
47One possible scenario is when output of an application has included
48hash data. For example, if you have used the Data::Dumper module to
49dump data into different files, and then compared the files to see
50whether the data has changed, now you will have false positives since
51the order in which hashes are dumped will vary. In general the cure
52is to sort the keys (or the values); in particular for Data::Dumper to
53use the C<Sortkeys> option. If some particular order is really
54important, use tied hashes: for example the Tie::IxHash module
55which by default preserves the order in which the hash elements
56were added.
57
58More subtle problem is reliance on the order of "global destruction".
59That is what happens at the end of execution: Perl destroys all data
60structures, including user data. If your destructors (the DESTROY
61subroutines) have assumed any particular ordering to the global
62destruction, there might be problems ahead. For example, in a
63destructor of one object you cannot assume that objects of any other
64class are still available, unless you hold a reference to them.
65If the environment variable PERL_DESTRUCT_LEVEL is set to a non-zero
66value, or if Perl is exiting a spawned thread, it will also destruct
67the ordinary references and the symbol tables that are no longer in use.
68You can't call a class method or an ordinary function on a class that
69has been collected that way.
70
71The hash randomisation is certain to reveal hidden assumptions about
72some particular ordering of hash elements, and outright bugs: it
73revealed a few bugs in the Perl core and core modules.
74
75To disable the hash randomisation in runtime, set the environment
76variable PERL_HASH_SEED to 0 (zero) before running Perl (for more
77information see L<perlrun/PERL_HASH_SEED>), or to disable the feature
78completely in compile time, compile with C<-DNO_HASH_SEED> (see F<INSTALL>).
79
80See L<perlsec/"Algorithmic Complexity Attacks"> for the original
81rationale behind this change.
82
83=head2 UTF-8 On Filehandles No Longer Activated By Locale
84
85In Perl 5.8.0 all filehandles, including the standard filehandles,
86were implicitly set to be in Unicode UTF-8 if the locale settings
87indicated the use of UTF-8. This feature caused too many problems,
88so the feature was turned off and redesigned: see L</"Core Enhancements">.
89
90=head2 Single-number v-strings are no longer v-strings before "=>"
91
92The version strings or v-strings (see L<perldata/"Version Strings">)
93feature introduced in Perl 5.6.0 has been a source of some confusion--
94especially when the user did not want to use it, but Perl thought it
95knew better. Especially troublesome has been the feature that before
96a "=>" a version string (a "v" followed by digits) has been interpreted
97as a v-string instead of a string literal. In other words:
98
99 %h = ( v65 => 42 );
100
101has meant since Perl 5.6.0
102
103 %h = ( 'A' => 42 );
104
105(at least in platforms of ASCII progeny) Perl 5.8.1 restores the
106more natural interpretation
107
108 %h = ( 'v65' => 42 );
109
110The multi-number v-strings like v65.66 and 65.66.67 still continue to
111be v-strings in Perl 5.8.
112
113=head2 (Win32) The -C Switch Has Been Repurposed
114
115The -C switch has changed in an incompatible way. The old semantics
116of this switch only made sense in Win32 and only in the "use utf8"
117universe in 5.6.x releases, and do not make sense for the Unicode
118implementation in 5.8.0. Since this switch could not have been used
119by anyone, it has been repurposed. The behavior that this switch
120enabled in 5.6.x releases may be supported in a transparent,
121data-dependent fashion in a future release.
122
123For the new life of this switch, see L<"UTF-8 no longer default under
124UTF-8 locales">, and L<perlrun/-C>.
125
126=head2 (Win32) The /d Switch Of cmd.exe
127
128Perl 5.8.1 uses the /d switch when running the cmd.exe shell
129internally for system(), backticks, and when opening pipes to external
130programs. The extra switch disables the execution of AutoRun commands
131from the registry, which is generally considered undesirable when
132running external programs. If you wish to retain compatibility with
133the older behavior, set PERL5SHELL in your environment to C<cmd /x/c>.
134
135=head1 Core Enhancements
136
137=head2 UTF-8 no longer default under UTF-8 locales
138
139In Perl 5.8.0 many Unicode features were introduced. One of them
140was found to be of more nuisance than benefit: the automagic
141(and silent) "UTF-8-ification" of filehandles, including the
142standard filehandles, if the user's locale settings indicated
143use of UTF-8.
144
145For example, if you had C<en_US.UTF-8> as your locale, your STDIN and
146STDOUT were automatically "UTF-8", in other words an implicit
147binmode(..., ":utf8") was made. This meant that trying to print, say,
148chr(0xff), ended up printing the bytes 0xc3 0xbf. Hardly what
149you had in mind unless you were aware of this feature of Perl 5.8.0.
150The problem is that the vast majority of people weren't: for example
151in RedHat releases 8 and 9 the B<default> locale setting is UTF-8, so
152all RedHat users got UTF-8 filehandles, whether they wanted it or not.
153The pain was intensified by the Unicode implementation of Perl 5.8.0
154(still) having nasty bugs, especially related to the use of s/// and
155tr///. (Bugs that have been fixed in 5.8.1)
156
157Therefore a decision was made to backtrack the feature and change it
158from implicit silent default to explicit conscious option. The new
159Perl command line option C<-C> and its counterpart environment
160variable PERL_UNICODE can now be used to control how Perl and Unicode
161interact at interfaces like I/O and for example the command line
162arguments. See L<perlrun/-C> and L<perlrun/PERL_UNICODE> for more
163information.
164
165=head2 Unsafe signals again available
166
167In Perl 5.8.0 the so-called "safe signals" were introduced. This
168means that Perl no longer handles signals immediately but instead
169"between opcodes", when it is safe to do so. The earlier immediate
170handling easily could corrupt the internal state of Perl, resulting
171in mysterious crashes.
172
173However, the new safer model has its problems too. Because now an
174opcode, a basic unit of Perl execution, is never interrupted but
175instead let to run to completion, certain operations that can take a
176long time now really do take a long time. For example, certain
177network operations have their own blocking and timeout mechanisms, and
178being able to interrupt them immediately would be nice.
179
180Therefore perl 5.8.1 introduces a "backdoor" to restore the pre-5.8.0
181(pre-5.7.3, really) signal behaviour. Just set the environment variable
182PERL_SIGNALS to C<unsafe>, and the old immediate (and unsafe)
183signal handling behaviour returns. See L<perlrun/PERL_SIGNALS>
184and L<perlipc/"Deferred Signals (Safe Signals)">.
185
186In completely unrelated news, you can now use safe signals with
187POSIX::SigAction. See L<POSIX/POSIX::SigAction>.
188
189=head2 Tied Arrays with Negative Array Indices
190
191Formerly, the indices passed to C<FETCH>, C<STORE>, C<EXISTS>, and
192C<DELETE> methods in tied array class were always non-negative. If
193the actual argument was negative, Perl would call FETCHSIZE implicitly
194and add the result to the index before passing the result to the tied
195array method. This behaviour is now optional. If the tied array class
196contains a package variable named C<$NEGATIVE_INDICES> which is set to
197a true value, negative values will be passed to C<FETCH>, C<STORE>,
198C<EXISTS>, and C<DELETE> unchanged.
199
200=head2 local ${$x}
201
202The syntaxes
203
204 local ${$x}
205 local @{$x}
206 local %{$x}
207
208now do localise variables, given that the $x is a valid variable name.
209
210=head2 Unicode Character Database 4.0.0
211
212The copy of the Unicode Character Database included in Perl 5.8 has
213been updated to 4.0.0 from 3.2.0. This means for example that the
214Unicode character properties are as in Unicode 4.0.0.
215
216=head2 Deprecation Warnings
217
218There is one new feature deprecation. Perl 5.8.0 forgot to add
219some deprecation warnings, these warnings have now been added.
220Finally, a reminder of an impending feature removal.
221
222=head3 (Reminder) Pseudo-hashes are deprecated (really)
223
224Pseudo-hashes were deprecated in Perl 5.8.0 and will be removed in
225Perl 5.10.0, see L<perl58delta> for details. Each attempt to access
226pseudo-hashes will trigger the warning C<Pseudo-hashes are deprecated>.
227If you really want to continue using pseudo-hashes but not to see the
228deprecation warnings, use:
229
230 no warnings 'deprecated';
231
232Or you can continue to use the L<fields> pragma, but please don't
233expect the data structures to be pseudohashes any more.
234
235=head3 (Reminder) 5.005-style threads are deprecated (really)
236
2375.005-style threads (activated by C<use Thread;>) were deprecated in
238Perl 5.8.0 and will be removed after Perl 5.8, see L<perl58delta> for
239details. Each 5.005-style thread creation will trigger the warning
240C<5.005 threads are deprecated>. If you really want to continue
241using the 5.005 threads but not to see the deprecation warnings, use:
242
243 no warnings 'deprecated';
244
245=head3 (Reminder) The $* variable is deprecated (really)
246
247The C<$*> variable controlling multi-line matching has been deprecated
248and will be removed after 5.8. The variable has been deprecated for a
249long time, and a deprecation warning C<Use of $* is deprecated> is given,
250now the variable will just finally be removed. The functionality has
251been supplanted by the C</s> and C</m> modifiers on pattern matching.
252If you really want to continue using the C<$*>-variable but not to see
253the deprecation warnings, use:
254
255 no warnings 'deprecated';
256
257=head2 Miscellaneous Enhancements
258
259C<map> in void context is no longer expensive. C<map> is now context
260aware, and will not construct a list if called in void context.
261
262If a socket gets closed by the server while printing to it, the client
263now gets a SIGPIPE. While this new feature was not planned, it fell
264naturally out of PerlIO changes, and is to be considered an accidental
265feature.
266
267PerlIO::get_layers(FH) returns the names of the PerlIO layers
268active on a filehandle.
269
270PerlIO::via layers can now have an optional UTF8 method to
271indicate whether the layer wants to "auto-:utf8" the stream.
272
273utf8::is_utf8() has been added as a quick way to test whether
274a scalar is encoded internally in UTF-8 (Unicode).
275
276=head1 Modules and Pragmata
277
278=head2 Updated Modules And Pragmata
279
280The following modules and pragmata have been updated since Perl 5.8.0:
281
282=over 4
283
284=item base
285
286=item B::Bytecode
287
288In much better shape than it used to be. Still far from perfect, but
289maybe worth a try.
290
291=item B::Concise
292
293=item B::Deparse
294
295=item Benchmark
296
297An optional feature, C<:hireswallclock>, now allows for high
298resolution wall clock times (uses Time::HiRes).
299
300=item ByteLoader
301
302See B::Bytecode.
303
304=item bytes
305
306Now has bytes::substr.
307
308=item CGI
309
310=item charnames
311
312One can now have custom character name aliases.
313
314=item CPAN
315
316There is now a simple command line frontend to the CPAN.pm
317module called F<cpan>.
318
319=item Data::Dumper
320
321A new option, Pair, allows choosing the separator between hash keys
322and values.
323
324=item DB_File
325
326=item Devel::PPPort
327
328=item Digest::MD5
329
330=item Encode
331
332Significant updates on the encoding pragma functionality
333(tr/// and the DATA filehandle, formats).
334
335If a filehandle has been marked as to have an encoding, unmappable
336characters are detected already during input, not later (when the
337corrupted data is being used).
338
339The ISO 8859-6 conversion table has been corrected (the 0x30..0x39
340erroneously mapped to U+0660..U+0669, instead of U+0030..U+0039). The
341GSM 03.38 conversion did not handle escape sequences correctly. The
342UTF-7 encoding has been added (making Encode feature-complete with
343Unicode::String).
344
345=item fields
346
347=item libnet
348
349=item Math::BigInt
350
351A lot of bugs have been fixed since v1.60, the version included in Perl
352v5.8.0. Especially noteworthy are the bug in Calc that caused div and mod to
353fail for some large values, and the fixes to the handling of bad inputs.
354
355Some new features were added, e.g. the broot() method, you can now pass
356parameters to config() to change some settings at runtime, and it is now
357possible to trap the creation of NaN and infinity.
358
359As usual, some optimizations took place and made the math overall a tad
360faster. In some cases, quite a lot faster, actually. Especially alternative
361libraries like Math::BigInt::GMP benefit from this. In addition, a lot of the
362quite clunky routines like fsqrt() and flog() are now much much faster.
363
364=item MIME::Base64
365
366=item NEXT
367
368Diamond inheritance now works.
369
370=item Net::Ping
371
372=item PerlIO::scalar
373
374Reading from non-string scalars (like the special variables, see
375L<perlvar>) now works.
376
377=item podlators
378
379=item Pod::LaTeX
380
381=item PodParsers
382
383=item Pod::Perldoc
384
385Complete rewrite. As a side-effect, no longer refuses to startup when
386run by root.
387
388=item Scalar::Util
389
390New utilities: refaddr, isvstring, looks_like_number, set_prototype.
391
392=item Storable
393
394Can now store code references (via B::Deparse, so not foolproof).
395
396=item strict
397
398Earlier versions of the strict pragma did not check the parameters
399implicitly passed to its "import" (use) and "unimport" (no) routine.
400This caused the false idiom such as:
401
402 use strict qw(@ISA);
403 @ISA = qw(Foo);