win32 tweaks
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
1 =head1 NAME
2
3 perldelta - what's new for perl5.005
4
5 =head1 DESCRIPTION
6
7 This document describes differences between the 5.004 release and this one.
8
9 [XXX this needs more verbose summaries of the sub topics, instead of just
10 the "See foo."  Scheduled for a second iteration. GSAR]
11
12 =head1 About the new versioning system
13
14 =head1 Incompatible Changes
15
16 =head2 WARNING:  This version is not binary compatible with Perl 5.004.
17
18 Starting with Perl 5.004_50 there were many deep and far-reaching changes
19 to the language internals.  If you have dynamically loaded extensions
20 that you built under perl 5.003 or 5.004, you can continue to use them
21 with 5.004, but you will need to rebuild and reinstall those extensions
22 to use them 5.005.  See L<INSTALL> for detailed instructions on how to
23 upgrade.
24
25 =head2 Default installation structure has changed
26
27 The new Configure defaults are designed to allow a smooth upgrade from
28 5.004 to 5.005, but you should read L<INSTALL> for a detailed
29 discussion of the changes in order to adapt them to your system.
30
31 =head2 Perl Source Compatibility
32
33 When none of the experimental features are enabled, there should be
34 no user-visible Perl source compatibility issue.
35
36 If threads are enabled, then some caveats apply. C<@_> and C<$_> become
37 lexical variables.  The effect of this should be largely transparent to
38 the user, but there are some boundary conditions under which user will
39 need to be aware of the issues. [XXX Add e.g. here.]
40
41 Some new keywords have been introduced.  These are generally expected to
42 have very little impact on compatibility.  See L</New C<INIT> keyword>,
43 L</New C<lock> keyword>, and L</New C<qr//> operator>.
44
45 Certain barewords are now reserved.  Use of these will provoke a warning
46 if you have asked for them with the C<-w> switch.
47 See L</C<our> is now a reserved word>.
48
49 =head2 C Source Compatibility
50
51 =item Core sources now require ANSI C compiler
52
53 =item Enabling threads has source compatibility issues
54
55 =head2 Binary Compatibility
56
57 This version is NOT binary compatible with older versions.  All extensions
58 will need to be recompiled.
59
60 =head2 Security fixes may affect compatibility
61
62 A few taint leaks and taint omissions have been corrected.  This may lead
63 to "failure" of scripts that used to work with older versions.  Compiling
64 with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes
65 to the tainting behavior.  But note that the resulting perl will have
66 known insecurities.
67
68 Oneliners with the C<-e> switch do not create temporary files anymore.
69
70 =head2 Relaxed new mandatory warnings introduced in 5.004
71
72 Many new warnings that were introduced in 5.004 have been made
73 optional.  Some of these warnings are still present, but perl's new
74 features make them less often a problem.  See L<New Diagnostics>.
75
76 =head2 Licensing
77
78 Perl has a new Social Contract for contributors.  See F<Porting/Contract>.
79
80 The license included in much of the Perl documentation has changed.
81 [XXX See where?]
82
83 =head1 Core Changes
84
85
86 =head2 Threads
87
88 WARNING: Threading is considered an experimental feature.  Details of the
89 implementation may change without notice.  There are known limitations
90 and and some bugs.
91
92 See L<README.threads>.
93
94 =head2 Compiler
95
96 WARNING: The Compiler and related tools are considered experimental.
97 Features may change without notice, and there are known limitations
98 and bugs.
99
100 The Compiler produces three different types of transformations of a
101 perl program.  The C backend generates C code that captures perl's state
102 just before execution begins.  It eliminates the compile-time overheads
103 of the regular perl interpreter, but the run-time performance remains
104 comparatively the same.  The CC backend generates optimized C code
105 equivivalent to the code path at run-time.  The CC backend has greater
106 potential for big optimizations, but only a few optimizations are
107 implemented currently.  The Bytecode backend generates a platform
108 independent bytecode representation of the interpreter's state
109 just before execution.  Thus, the Bytecode back end also eliminates
110 much of the compilation overhead of the interpreter.
111
112 The compiler comes with several valuable utilities.
113
114 C<B::Lint> is an experimental module to detect and warn about suspicious
115 code, especially the cases that the C<-w> switch does not detect.
116
117 C<B::Deparse> can be used to demystify perl code, and understand
118 how perl optimizes certain constructs.
119
120 C<B::Xref> generates cross reference reports of all definition and use
121 of variables, subroutines and formats in a program.
122
123 C<B::Showlex> show the lexical variables used by a subroutine or file
124 at a glance.
125
126 C<perlcc> is a simple frontend for compiling perl.
127
128 See C<ext/B/README>.
129
130 =head2 Regular Expressions
131
132 See L<perlre> and L<perlop>.
133
134 =head2   Improved malloc()
135
136 See banner at the beginning of C<malloc.c> for details.
137
138 =head2 Quicksort is internally implemented
139
140 See C<perlfunc/sort>.
141
142 =head2 Reliable signals
143
144 Two kinds.
145
146 Via C<Thread::Signal>.
147
148 Via switched runtime op loop.  [XXX Not yet available.]
149
150 =head2 Reliable stack pointers
151
152 The internals now reallocate the perl stack only at predictable times.
153 In particular, magic calls never trigger reallocations of the stack,
154 because all reentrancy of the runtime is handled using a "stack of stacks".
155 This should improve reliability of cached stack pointers in the internals
156 and in XSUBs.
157
158 =head2 Behavior of local() on array and hash elements is now well-defined
159
160 See L<perlsub/"Temporary Values via local()">.
161
162 =head2 C<%!> is transparently tied to the L<Errno> module
163
164 See L<perlvar>, and L<Errno>.
165
166 =head2 Pseudo-hashes are supported
167
168 See L<perlref>.
169
170 =head2 C<EXPR foreach EXPR> is supported
171
172 See L<perlsyn>.
173
174 =head2 Keywords can be globally overridden
175
176 See L<perlsub>.
177
178 =head2 C<$^E> is meaningful on Win32
179
180 See L<perlvar>.
181
182 =head2 C<foreach (1..1000000)> optimized
183
184 C<foreach (1..1000000)> is now optimized into a counting loop.  It does
185 not try to allocate a 1000000-size list anymore.
186
187 =head2 C<Foo::> can be used as implicitly quoted package name
188
189 [XXX See what?]
190
191 =head2 C<exists $Foo::{Bar::}> tests existence of a package
192
193 [XXX See what?]
194
195 =head2 Better locale support
196
197 See L<perllocale>.
198
199 =head2 Experimental support for 64-bit platforms
200
201 Perl5 has always had 64-bit support on systems with 64-bit longs.
202 Starting with 5.005, the beginnings of experimental support for systems
203 with 32-bit long and 64-bit 'long long' integers has been added.
204 If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
205 define it in perl.h) then perl will be built with 'long long' support.
206 There will be many compiler warnings, and the resultant perl may not
207 work on all systems.  There are many other issues related to
208 third-party extensions and libraries.  This option exists to allow
209 people to work on those issues.
210
211 =head2 prototype() returns useful results on builtins
212
213 See L<perlfunc/prototype>.
214
215 =head2 Extended support for exception handling
216
217 C<die()> now accepts a reference value, and C<$@> gets set to that
218 value in exception traps.  This makes it possible to propagate
219 exception objects.  See L<perlfunc/eval>.  [XXX there's nothing
220 about this in perlfunc/eval yet.]
221
222 =head2 Re-blessing in DESTROY() supported for chaining DESTROY() methods
223
224 See L<perlobj/Destructors>.
225
226 =head2 All C<printf> format conversions are handled internally
227
228 See L<perlfunc/printf>.
229
230 =head2 New C<INIT> keyword
231
232 C<INIT> subs are like C<BEGIN> and C<END>, but they get run just before
233 the perl runtime begins execution.  e.g., the Perl Compiler makes use of
234 C<INIT> blocks to initialize and resolve pointers to XSUBs.
235
236 [XXX Needs to be documented in perlsub or perlmod.]
237
238 =head2 New C<lock> keyword
239
240 The C<lock> keyword is the fundamental synchronization primitive
241 in threaded perl.  When threads are not enabled, it is currently a noop.
242
243 To minimize impact on source compatibility this keyword is "weak", i.e., any
244 user-defined subroutine of the same name overrides it, unless a C<use Thread>
245 has been seen.
246
247 =head2 New C<qr//> operator
248
249 The C<qr//> operator, which is syntactically similar to the other quote-like
250 operators, is used to create precompiled regular expressions.  This compiled
251 form can now be explicitly passed around in variables, and interpolated in
252 other regular expressions.  See L<perlop>.
253
254 =head2 C<our> is now a reserved word
255
256 =head2 Tied arrays are now fully supported
257
258 See L<Tie::Array>.
259
260 =head2 Tied handles support is better
261
262 Several missing hooks have been added.  There is also a new base class for
263 TIEARRAY implementations.  See L<Tie::Array>.
264
265 =head2 4th argument to substr
266
267 substr() can now both return and replace in one operation.  The optional
268 4th argument is the replacement string.  See L<perlfunc/substr>.
269
270 =head2 Negative LENGTH argument to splice
271
272 Splice() with a negative LENGTH argument now work similar to what the
273 LENGTH did for substr().  Previously a negative LENGTH was treated as
274 0.  See L<perlfunc/splice>.
275
276 =head2 Magic lvalues are now more magical
277
278 When you say something like C<substr($x, 5) = "hi">, the scalar returned
279 by substr() is special, in that any modifications to it affect $x.
280 (This is called a 'magic lvalue' because an 'lvalue' is something on
281 the left side of an assignment.)  Normally, this is exactly what you
282 would expect to happen, but Perl uses the same magic if you use substr(),
283 pos(), or vec() in a context where they might be modified, like taking
284 a reference with C<\> or as an argument to a sub that modifies C<@_>.
285 In previous versions, this 'magic' only went one way, but now changes
286 to the scalar the magic refers to ($x in the above example) affect the
287 magic lvalue too. For instance, this code now acts differently:
288
289     $x = "hello";
290     sub printit {
291         $x = "g'bye";
292         print $_[0], "\n";
293     }
294     printit(substr($x, 0, 5));
295
296 In previous versions, this would print "hello", but it now prints "g'bye".
297
298 =head2 E<lt>E<gt> now reads in records
299
300 If C<$/> is a referenence to an integer, or a scalar that holds an integer,
301 E<lt>E<gt> will read in records instead of lines. For more info, see
302 L<perlvar/$/>.
303
304 =head1 Supported Platforms
305
306 Configure has many incremental improvements.  Site-wide policy for building
307 perl can now be made persistent, via Policy.sh.  Configure also records
308 the command-line arguments used in F<config.sh>.
309
310 =head2 New Platforms
311
312 BeOS is now supported.  See L<README.beos>.
313
314 DOS is now supported under the DJGPP tools.  See L<README.dos>.
315
316 MPE/iX is now supported.  See L<README.mpeix>.
317
318 =head2 Changes in existing support
319
320 Win32 support has been vastly enhanced.  Support for Perl Object, a C++
321 encapsulation of Perl.  GCC and EGCS are now supported on Win32.
322 [XXX Perl Object needs a big explanation elsewhere, and a pointer to
323 that location here.]
324
325 VMS configuration system has been rewritten.  See L<README.vms>.
326
327 OpenBSD better supported.  [XXX what others?]
328
329 =head1 Modules and Pragmata
330
331 =head2 New Modules
332
333 =over
334
335 =item B
336
337 Perl compiler and tools.  See [XXX what?].
338
339 =item Data::Dumper
340
341 A module to pretty print Perl data.  See L<Data::Dumper>.
342
343 =item Errno
344
345 A module to look up errors more conveniently.  See L<Errno>.
346
347 =item File::Spec
348
349 A portable API for file operations.
350
351 =item ExtUtils::Installed
352
353 Query and manage installed modules.
354
355 =item ExtUtils::Packlist
356
357 Manipulate .packlist files.
358
359 =item Fatal
360
361 Make functions/builtins succeed or die.
362
363 =item IPC::SysV
364
365 Constants and other support infrastructure for System V IPC operations
366 in perl.
367
368 =item Test
369
370 A framework for writing testsuites.
371
372 =item Tie::Array
373
374 Base class for tied arrays.
375
376 =item Tie::Handle
377
378 Base class for tied handles.
379
380 =item Thread
381
382 Perl thread creation, manipulation, and support.
383
384 =item attrs
385
386 Set subroutine attributes.
387
388 =item fields
389
390 Compile-time class fields.
391
392 =item re
393
394 Various pragmata to control behavior of regular expressions.
395
396 =back
397
398 =head2 Changes in existing modules
399
400 =over
401
402 =item CGI
403
404 CGI has been updated to version 2.42.
405
406 =item POSIX
407
408 POSIX now has its own platform-specific hints files.
409
410 =item DB_File
411
412 DB_File supports version 2.x of Berkeley DB.  See C<ext/DB_File/Changes>.
413
414 =item MakeMaker
415
416 MakeMaker now supports writing empty makefiles, provides a way to
417 specify that site umask() policy should be honored.  There is also
418 better support for manipulation of .packlist files, and getting
419 information about installed modules.
420
421 Extensions that have both architecture-dependent and
422 architecture-independent files are now always installed completely in
423 the architecture-dependent locations.  Previously, the shareable parts
424 were shared both across architectures and across perl versions and were
425 therefore liable to be overwritten with newer versions that might have
426 subtle incompatibilities.
427
428 =item CPAN
429
430 [XXX What?]
431
432 =item Cwd
433
434 Cwd::cwd is faster on most platforms.
435
436 =item Benchmark
437
438 Keeps better time.
439
440 =back
441
442 =head1 Utility Changes
443
444 h2ph and related utilities have been vastly overhauled.
445
446 perlcc, a new experimental front end for the compiler is available.
447
448 The crude GNU configure emulator is now called configure.gnu.
449
450 =head1 API Changes
451
452 =head2 Incompatible Changes
453
454 =head2 Deprecations, Extensions
455
456 =head2 C++ Support
457
458 =head1 Documentation Changes
459
460 Config.pm now has a glossary of variables.
461
462 Porting/patching.pod has detailed instructions on how to create and
463 submit patches for perl.
464
465 =head1 New Diagnostics
466
467 =over
468
469 =item Ambiguous call resolved as CORE::%s(), qualify as such or use &
470
471 (W) A subroutine you have declared has the same name as a Perl keyword,
472 and you have used the name without qualification for calling one or the
473 other.  Perl decided to call the builtin because the subroutine is
474 not imported.
475
476 To force interpretation as a subroutine call, either put an ampersand
477 before the subroutine name, or qualify the name with its package.
478 Alternatively, you can import the subroutine (or pretend that it's
479 imported with the C<use subs> pragma).
480
481 To silently interpret it as the Perl operator, use the C<CORE::> prefix
482 on the operator (e.g. C<CORE::log($x)>) or by declaring the subroutine
483 to be an object method (see L<attrs>).
484
485 =item Bad index while coercing array into hash
486
487 (F) The index looked up in the hash found as the 0'th element of a
488 pseudo-hash is not legal.  Index values must be at 1 or greater.
489 See L<perlref>.
490
491 =item Bareword "%s" refers to nonexistent package
492
493 (W) You used a qualified bareword of the form C<Foo::>, but
494 the compiler saw no other uses of that namespace before that point.
495 Perhaps you need to predeclare a package?
496
497 =item Can't call method "%s" on an undefined value
498
499 (F) You used the syntax of a method call, but the slot filled by the
500 object reference or package name contains an undefined value.
501 Something like this will reproduce the error:
502
503     $BADREF = 42;
504     process $BADREF 1,2,3;
505     $BADREF->process(1,2,3);
506
507 =item Can't coerce array into hash
508
509 (F) You used an array where a hash was expected, but the array has no
510 information on how to map from keys to array indices.  You can do that
511 only with arrays that have a hash reference at index 0.
512
513 =item Can't goto subroutine from an eval-string
514
515 (F) The "goto subroutine" call can't be used to jump out of an eval "string".
516 (You can use it to jump out of an eval {BLOCK}, but you probably don't want to.)
517
518 =item Can't localize pseudo-hash element
519
520 (F) You said something like C<local $ar-E<gt>{'key'}>, where $ar is
521 a reference to a pseudo-hash.  That hasn't been implemented yet, but
522 you can get a similar effect by localizing the corresponding array
523 element directly -- C<local $ar-E<gt>[$ar-E<gt>[0]{'key'}]>.
524
525 =item Can't use %%! because Errno.pm is not available
526
527 (F) The first time the %! hash is used, perl automatically loads the
528 Errno.pm module. The Errno module is expected to tie the %! hash to
529 provide symbolic names for C<$!> errno values.
530
531 =item Cannot find an opnumber for "%s"
532
533 (F) A string of a form C<CORE::word> was given to prototype(), but
534 there is no builtin with the name C<word>.
535
536 =item Character class syntax [. .] is reserved for future extensions
537
538 (W) Within regular expression character classes ([]) the syntax beginning
539 with "[." and ending with ".]" is reserved for future extensions.
540 If you need to represent those character sequences inside a regular
541 expression character class, just quote the square brackets with the
542 backslash: "\[." and ".\]".
543
544 =item Character class syntax [: :] is reserved for future extensions
545
546 (W) Within regular expression character classes ([]) the syntax beginning
547 with "[:" and ending with ":]" is reserved for future extensions.
548 If you need to represent those character sequences inside a regular
549 expression character class, just quote the square brackets with the
550 backslash: "\[:" and ":\]".
551
552 =item Character class syntax [= =] is reserved for future extensions
553
554 (W) Within regular expression character classes ([]) the syntax
555 beginning with "[=" and ending with "=]" is reserved for future extensions.
556 If you need to represent those character sequences inside a regular
557 expression character class, just quote the square brackets with the
558 backslash: "\[=" and "=\]".
559
560 =item %s: Eval-group in insecure regular expression
561
562 (F) Perl detected tainted data when trying to compile a regular expression
563 that contains the C<(?{ ... })> zero-width assertion, which is unsafe.
564 See L<perlre/(?{ code })>, and L<perlsec>.
565
566 =item %s: Eval-group not allowed, use re 'eval'
567
568 (F) A regular expression contained the C<(?{ ... })> zero-width assertion,
569 but that construct is only allowed when the C<use re 'eval'> pragma is
570 in effect.  See L<perlre/(?{ code })>.
571
572 =item %s: Eval-group not allowed at run time
573
574 (F) Perl tried to compile a regular expression containing the C<(?{ ... })>
575 zero-width assertion at run time, as it would when the pattern contains
576 interpolated values.  Since that is a security risk, it is not allowed.
577 If you insist, you may still do this by explicitly building the pattern
578 from an interpolated string at run time and using that in an eval().
579 See L<perlre/(?{ code })>.
580
581 =item Explicit blessing to '' (assuming package main)
582
583 (W) You are blessing a reference to a zero length string.  This has
584 the effect of blessing the reference into the package main.  This is
585 usually not what you want.  Consider providing a default target
586 package, e.g. bless($ref, $p or 'MyPackage');
587
588 =item Illegal hex digit ignored
589
590 (W) You may have tried to use a character other than 0 - 9 or A - F in a
591 hexadecimal number.  Interpretation of the hexadecimal number stopped
592 before the illegal character.
593
594 =item No such array field
595
596 (F) You tried to access an array as a hash, but the field name used is
597 not defined.  The hash at index 0 should map all valid field names to
598 array indices for that to work.
599
600 =item No such field "%s" in variable %s of type %s
601
602 (F) You tried to access a field of a typed variable where the type
603 does not know about the field name.  The field names are looked up in
604 the %FIELDS hash in the type package at compile time.  The %FIELDS hash
605 is usually set up with the 'fields' pragma.
606
607 =item Out of memory during ridiculously large request
608
609 (F) You can't allocate more than 2^31+"small amount" bytes.  This error
610 is most likely to be caused by a typo in the Perl program. e.g., C<$arr[time]>
611 instead of C<$arr[$time]>.
612
613 =item Range iterator outside integer range
614
615 (F) One (or both) of the numeric arguments to the range operator ".."
616 are outside the range which can be represented by integers internally.
617 One possible workaround is to force Perl to use magical string
618 increment by prepending "0" to your numbers.
619
620 =item Recursive inheritance detected while looking for method '%s' in package '%s'
621
622 (F) More than 100 levels of inheritance were encountered while invoking a
623 method.  Probably indicates an unintended loop in your inheritance hierarchy.
624
625 =item Reference found where even-sized list expected
626
627 (W) You gave a single reference where Perl was expecting a list with
628 an even number of elements (for assignment to a hash). This
629 usually means that you used the anon hash constructor when you meant 
630 to use parens. In any case, a hash requires key/value B<pairs>.
631
632     %hash = { one => 1, two => 2, };   # WRONG
633     %hash = [ qw/ an anon array / ];   # WRONG
634     %hash = ( one => 1, two => 2, );   # right
635     %hash = qw( one 1 two 2 );                 # also fine
636
637 =item Undefined value assigned to typeglob
638
639 (W) An undefined value was assigned to a typeglob, a la C<*foo = undef>.
640 This does nothing.  It's possible that you really mean C<undef *foo>.
641
642 =item Use of reserved word "%s" is deprecated
643
644 (D) The indicated bareword is a reserved word.  Future versions of perl
645 may use it as a keyword, so you're better off either explicitly quoting
646 the word in a manner appropriate for its context of use, or using a
647 different name altogether.  The warning can be suppressed for subroutine
648 names by either adding a C<&> prefix, or using a package qualifier,
649 e.g. C<&our()>, or C<Foo::our()>.
650
651 =item perl: warning: Setting locale failed.
652
653 (S) The whole warning message will look something like:
654
655        perl: warning: Setting locale failed.
656        perl: warning: Please check that your locale settings:
657                LC_ALL = "En_US",
658                LANG = (unset)
659            are supported and installed on your system.
660        perl: warning: Falling back to the standard locale ("C").
661
662 Exactly what were the failed locale settings varies.  In the above the
663 settings were that the LC_ALL was "En_US" and the LANG had no value.
664 This error means that Perl detected that you and/or your system
665 administrator have set up the so-called variable system but Perl could
666 not use those settings.  This was not dead serious, fortunately: there
667 is a "default locale" called "C" that Perl can and will use, the
668 script will be run.  Before you really fix the problem, however, you
669 will get the same error message each time you run Perl.  How to really
670 fix the problem can be found in L<perllocale> section B<LOCALE PROBLEMS>.
671
672 =back
673
674
675 =head1 Obsolete Diagnostics
676
677 =over
678
679 =item Can't mktemp()
680
681 (F) The mktemp() routine failed for some reason while trying to process
682 a B<-e> switch.  Maybe your /tmp partition is full, or clobbered.
683
684 =item Can't write to temp file for B<-e>: %s
685
686 (F) The write routine failed for some reason while trying to process
687 a B<-e> switch.  Maybe your /tmp partition is full, or clobbered.
688
689 =item Cannot open temporary file
690
691 (F) The create routine failed for some reason while trying to process
692 a B<-e> switch.  Maybe your /tmp partition is full, or clobbered.
693
694
695 =back
696
697 =head1 BUGS
698
699 If you find what you think is a bug, you might check the headers of
700 recently posted articles in the comp.lang.perl.misc newsgroup.
701 There may also be information at http://www.perl.com/perl/, the Perl
702 Home Page.
703
704 If you believe you have an unreported bug, please run the B<perlbug>
705 program included with your release.  Make sure you trim your bug down
706 to a tiny but sufficient test case.  Your bug report, along with the
707 output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
708 analysed by the Perl porting team.
709
710 =head1 SEE ALSO
711
712 The F<Changes> file for exhaustive details on what changed.
713
714 The F<INSTALL> file for how to build Perl.
715
716 The F<README> file for general stuff.
717
718 The F<Artistic> and F<Copying> files for copyright information.
719
720 =head1 HISTORY
721
722 =cut