[inseparable changes from match from perl-5.003_97a to perl-5.003_97b]
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
1 =head1 NAME
2
3 perldelta - what's new for perl5.004
4
5 =head1 DESCRIPTION
6
7 This document describes differences between the 5.003 release (as
8 documented in I<Programming Perl>, second edition--the Camel Book) and
9 this one.
10
11 =head1 Supported Environments
12
13 Perl5.004 builds out of the box on Unix, Plan9, LynxOS, VMS, OS/2,
14 QNX, and AmigaOS.
15
16 =head1 Core Changes
17
18 Most importantly, many bugs were fixed.  See the F<Changes>
19 file in the distribution for details.
20
21 =head2 Compilation option: Binary compatibility with 5.003
22
23 There is a new Configure question that asks if you want to maintain
24 binary compatibility with Perl 5.003.  If you choose binary
25 compatibility, you do not have to recompile your extensions, but you
26 might have symbol conflicts if you embed Perl in another application,
27 just as in the 5.003 release.  By default, binary compatibility
28 is preserved at the expense of symbol table pollution.
29
30 =head2 $PERL5OPT environment variable
31
32 You may now put Perl options in the $PERL5OPT environment variable.
33 Unless Perl is running with taint checks, it will interpret this
34 variable as if its contents had appeared on a "#!perl" line at the
35 beginning of your script, except that hyphens are optional.  PERL5OPT
36 may only be used to set the following switches: B<-[DIMUdmw]>.
37
38 =head2 More precise warnings
39
40 If you removed the B<-w> option from your Perl 5.003 scripts because it
41 made Perl too verbose, we recommend that you try putting it back when
42 you upgrade to Perl 5.004.  Each new perl version tends to remove some
43 undesirable warnings, while adding new warnings that may catch bugs in
44 your scripts.
45
46 =head2 Deprecated: Inherited C<AUTOLOAD> for non-methods
47
48 Before Perl 5.004, C<AUTOLOAD> functions were looked up as methods
49 (using the C<@ISA> hierarchy), even when the function to be autoloaded
50 was called as a plain function (e.g. C<Foo::bar()>), not a method
51 (e.g. C<Foo->bar()> or C<$obj->bar()>).
52
53 Perl 5.005 will use method lookup only for methods' C<AUTOLOAD>s.
54 However, there is a significant base of existing code that may be using
55 the old behavior.  So, as an interim step, Perl 5.004 issues an optional
56 warning when a non-method uses an inherited C<AUTOLOAD>.
57
58 The simple rule is:  Inheritance will not work when autoloading
59 non-methods.  The simple fix for old code is:  In any module that used to
60 depend on inheriting C<AUTOLOAD> for non-methods from a base class named
61 C<BaseClass>, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup.
62
63 =head2 Subroutine arguments created only when they're modified
64
65 In Perl 5.004, nonexistent array and hash elements used as subroutine
66 parameters are brought into existence only if they are actually
67 assigned to (via C<@_>).
68
69 Earlier versions of Perl vary in their handling of such arguments.
70 Perl versions 5.002 and 5.003 always brought them into existence.
71 Perl versions 5.000, 5.001, and 5.002 brought them into existence only
72 if they were not the first argument (which was almost certainly a
73 bug).  Earlier versions of Perl never brought them into existence.
74
75 For example, given this code:
76
77      undef @a; undef %a;
78      sub show { print $_[0] };
79      sub change { $_[0]++ };
80      show($a[2]);
81      change($a{b});
82
83 After this code executes in Perl 5.004, $a{b} exists but $a[2] does
84 not.  In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed
85 (but $a[2]'s value would have been undefined).
86
87 =head2 C<$)> is writable
88
89 The C<$)> special variable has always (well, in Perl 5, at least)
90 reflected not only the current effective group, but also the group
91 list as returned by the C<getgroups()> C function (if there is one).
92 However, due to an oversight, assigning to C<$)> has not called
93 C<setgroups()>, only C<setegid()>.
94
95 In Perl 5.004, assigning to C<$)> is exactly symmetrical with
96 examining it: The first number in its string value is used as the
97 effective gid, and all the others are passed to the C<setgroups()> C
98 function (if there is one).
99
100 =head2 Fixed parsing of $$<digit>, &$<digit>, etc.
101
102 Perl versions before 5.004 misinterpreted any type marker followed by
103 "$" and a digit.  For example, "$$0" was incorrectly taken to mean
104 "${$}0" instead of "${$0}".  This bug is (mostly) fixed in Perl 5.004.
105
106 However, the developers of Perl 5.004 could not fix this bug completely,
107 because at least two widely-used modules depend on the old meaning of
108 "$$0" in a string.  So Perl 5.004 still interprets "$$<digit>" in the
109 old (broken) way inside strings; but it generates this message as a
110 warning.  And in Perl 5.005, this special treatment will cease.
111
112 =head2 No resetting of $. on implicit close
113
114 The documentation for Perl 5.0 has always stated that C<$.> is I<not>
115 reset when an already-open file handle is reopened with no intervening
116 call to C<close>.  Due to a bug, perl versions 5.000 through 5.003
117 I<did> reset C<$.> under that circumstance; Perl 5.004 does not.
118
119 =head2 C<wantarray> may return undef
120
121 The C<wantarray> operator returns true if a subroutine is expected to
122 return a list, and false otherwise.  In Perl 5.004, C<wantarray> can
123 also return the undefined value if a subroutine's return value will
124 not be used at all, which allows subroutines to avoid a time-consuming
125 calculation of a return value if it isn't going to be used.
126
127 =head2 Changes to tainting checks
128
129 A bug in previous versions may have failed to detect some insecure
130 conditions when taint checks are turned on. (Taint checks are used
131 in setuid or setgid scripts, or when explicitly turned on with the
132 C<-T> invocation option.) Although it's unlikely, this may cause a
133 previously-working script to now fail -- which should be construed
134 as a blessing, since that indicates a potentially-serious security
135 hole was just plugged.
136
137 =head2 New Opcode module and revised Safe module
138
139 A new Opcode module supports the creation, manipulation and
140 application of opcode masks.  The revised Safe module has a new API
141 and is implemented using the new Opcode module.  Please read the new
142 Opcode and Safe documentation.
143
144 =head2 Embedding improvements
145
146 In older versions of Perl it was not possible to create more than one
147 Perl interpreter instance inside a single process without leaking like a
148 sieve and/or crashing.  The bugs that caused this behavior have all been
149 fixed.  However, you still must take care when embedding Perl in a C
150 program.  See the updated perlembed manpage for tips on how to manage
151 your interpreters.
152
153 =head2 Internal change: FileHandle class based on IO::* classes
154
155 File handles are now stored internally as type IO::Handle.  The
156 FileHandle module is still supported for backwards compatibility, but
157 it is now merely a front end to the IO::* modules -- specifically,
158 IO::Handle, IO::Seekable, and IO::File.  We suggest, but do not
159 require, that you use the IO::* modules in new code.
160
161 In harmony with this change, C<*GLOB{FILEHANDLE}> is now a
162 backward-compatible synonym for C<*STDOUT{IO}>.
163
164 =head2 Internal change: PerlIO abstraction interface
165
166 It is now possible to build Perl with AT&T's sfio IO package
167 instead of stdio.  See L<perlapio> for more details, and
168 the F<INSTALL> file for how to use it.
169
170 =head2 New and changed builtin variables
171
172 =over
173
174 =item $^E
175
176 Extended error message on some platforms.  (Also known as
177 $EXTENDED_OS_ERROR if you C<use English>).
178
179 =item $^H
180
181 The current set of syntax checks enabled by C<use strict>.  See the
182 documentation of C<strict> for more details.  Not actually new, but
183 newly documented.
184 Because it is intended for internal use by Perl core components,
185 there is no C<use English> long name for this variable.
186
187 =item $^M
188
189 By default, running out of memory it is not trappable.  However, if
190 compiled for this, Perl may use the contents of C<$^M> as an emergency
191 pool after die()ing with this message.  Suppose that your Perl were
192 compiled with -DEMERGENCY_SBRK and used Perl's malloc.  Then
193
194     $^M = 'a' x (1<<16);
195
196 would allocate a 64K buffer for use when in emergency.
197 See the F<INSTALL> file for information on how to enable this option.
198 As a disincentive to casual use of this advanced feature,
199 there is no C<use English> long name for this variable.
200
201 =back
202
203 =head2 New and changed builtin functions
204
205 =over
206
207 =item delete on slices
208
209 This now works.  (e.g. C<delete @ENV{'PATH', 'MANPATH'}>)
210
211 =item flock
212
213 is now supported on more platforms, prefers fcntl to lockf when
214 emulating, and always flushes before (un)locking.
215
216 =item printf and sprintf
217
218 now support "%i" as a synonym for "%d", and the "h" modifier.
219 So "%hi" means "short integer in decimal", and "%ho" means
220 "unsigned short integer as octal".
221
222 =item keys as an lvalue
223
224 As an lvalue, C<keys> allows you to increase the number of hash buckets
225 allocated for the given hash.  This can gain you a measure of efficiency if
226 you know the hash is going to get big.  (This is similar to pre-extending
227 an array by assigning a larger number to $#array.)  If you say
228
229     keys %hash = 200;
230
231 then C<%hash> will have at least 200 buckets allocated for it.  These
232 buckets will be retained even if you do C<%hash = ()>; use C<undef
233 %hash> if you want to free the storage while C<%hash> is still in scope.
234 You can't shrink the number of buckets allocated for the hash using
235 C<keys> in this way (but you needn't worry about doing this by accident,
236 as trying has no effect).
237
238 =item my() in Control Structures
239
240 You can now use my() (with or without the parentheses) in the control
241 expressions of control structures such as:
242
243     while (defined(my $line = <>)) {
244         $line = lc $line;
245     } continue {
246         print $line;
247     }
248
249     if ((my $answer = <STDIN>) =~ /^y(es)?$/i) {
250         user_agrees();
251     } elsif ($answer =~ /^n(o)?$/i) {
252         user_disagrees();
253     } else {
254         chomp $answer;
255         die "`$answer' is neither `yes' nor `no'";
256     }
257
258 Also, you can declare a foreach loop control variable as lexical by
259 preceding it with the word "my".  For example, in:
260
261     foreach my $i (1, 2, 3) {
262         some_function();
263     }
264
265 $i is a lexical variable, and the scope of $i extends to the end of
266 the loop, but not beyond it.
267
268 Note that you still cannot use my() on global punctuation variables
269 such as $_ and the like.
270
271 =item unpack() and pack()
272
273 A new format 'w' represents a BER compressed integer (as defined in
274 ASN.1).  Its format is a sequence of one or more bytes, each of which
275 provides seven bits of the total value, with the most significant
276 first.  Bit eight of each byte is set, except for the last byte, in
277 which bit eight is clear.
278
279 =item use VERSION
280
281 If the first argument to C<use> is a number, it is treated as a version
282 number instead of a module name.  If the version of the Perl interpreter
283 is less than VERSION, then an error message is printed and Perl exits
284 immediately.  Because C<use> occurs at compile time, this check happens
285 immediately during the compilation process, unlike C<require VERSION>,
286 which waits until runtime for the check.  This is often useful if you
287 need to check the current Perl version before C<use>ing library modules
288 which have changed in incompatible ways from older versions of Perl.
289 (We try not to do this more than we have to.)
290
291 =item use Module VERSION LIST
292
293 If the VERSION argument is present between Module and LIST, then the
294 C<use> will call the VERSION method in class Module with the given
295 version as an argument.  The default VERSION method, inherited from
296 the UNIVERSAL class, croaks if the given version is larger than the
297 value of the variable $Module::VERSION.  (Note that there is not a
298 comma after VERSION!)
299
300 This version-checking mechanism is similar to the one currently used
301 in the Exporter module, but it is faster and can be used with modules
302 that don't use the Exporter.  It is the recommended method for new
303 code.
304
305 =item prototype(FUNCTION)
306
307 Returns the prototype of a function as a string (or C<undef> if the
308 function has no prototype).  FUNCTION is a reference to or the name of the
309 function whose prototype you want to retrieve.
310 (Not actually new; just never documented before.)
311
312 =item srand
313
314 The default seed for C<srand>, which used to be C<time>, has been changed.
315 Now it's a heady mix of difficult-to-predict system-dependent values,
316 which should be sufficient for most everyday purposes.
317
318 Previous to version 5.004, calling C<rand> without first calling C<srand>
319 would yield the same sequence of random numbers on most or all machines.
320 Now, when perl sees that you're calling C<rand> and haven't yet called
321 C<srand>, it calls C<srand> with the default seed. You should still call
322 C<srand> manually if your code might ever be run on a pre-5.004 system,
323 of course, or if you want a seed other than the default.
324
325 =item $_ as Default
326
327 Functions documented in the Camel to default to $_ now in
328 fact do, and all those that do are so documented in L<perlfunc>.
329
330 =item C<m//g> does not trigger a pos() reset on failure
331
332 The C<m//g> match iteration construct used to reset the iteration
333 when it failed to match (so that the next C<m//g> match would start at
334 the beginning of the string).  You now have to explicitly do a
335 C<pos $str = 0;> to reset the "last match" position, or modify the
336 string in some way.  This change makes it practical to chain C<m//g>
337 matches together in conjunction with ordinary matches using the C<\G>
338 zero-width assertion.  See L<perlop> and L<perlre>.
339
340 =item C<m//x> ignores whitespace before ?*+{}
341
342 The C<m//x> construct has always been intended to ignore all unescaped
343 whitespace.  However, before Perl 5.004, whitespace had the effect of
344 escaping repeat modifiers like "*" or "?"; for example, C</a *b/x> was
345 (mis)interpreted as C</a\*b/x>.  This bug has been fixed in 5.004.
346
347 =item nested C<sub{}> closures work now
348
349 Prior to the 5.004 release, nested anonymous functions didn't work
350 right.  They do now.
351
352 =item formats work right on changing lexicals
353
354 Just like anonymous functions that contain lexical variables
355 that change (like a lexical index variable for a C<foreach> loop),
356 formats now work properly.  For example, this silently failed
357 before, and is fine now:
358
359     my $i;
360     foreach $i ( 1 .. 10 ) {
361         format =
362         my i is @#
363         $i
364     .
365         write;
366     }
367
368 =back
369
370 =head2 New builtin methods
371
372 The C<UNIVERSAL> package automatically contains the following methods that
373 are inherited by all other classes:
374
375 =over
376
377 =item isa(CLASS)
378
379 C<isa> returns I<true> if its object is blessed into a subclass of C<CLASS>
380
381 C<isa> is also exportable and can be called as a sub with two arguments. This
382 allows the ability to check what a reference points to. Example:
383
384     use UNIVERSAL qw(isa);
385
386     if(isa($ref, 'ARRAY')) {
387        ...
388     }
389
390 =item can(METHOD)
391
392 C<can> checks to see if its object has a method called C<METHOD>,
393 if it does then a reference to the sub is returned; if it does not then
394 I<undef> is returned.
395
396 =item VERSION( [NEED] )
397
398 C<VERSION> returns the version number of the class (package).  If the
399 NEED argument is given then it will check that the current version (as
400 defined by the $VERSION variable in the given package) not less than
401 NEED; it will die if this is not the case.  This method is normally
402 called as a class method.  This method is called automatically by the
403 C<VERSION> form of C<use>.
404
405     use A 1.2 qw(some imported subs);
406     # implies:
407     A->VERSION(1.2);
408
409 =back
410
411 B<NOTE:> C<can> directly uses Perl's internal code for method lookup, and
412 C<isa> uses a very similar method and caching strategy. This may cause
413 strange effects if the Perl code dynamically changes @ISA in any package.
414
415 You may add other methods to the UNIVERSAL class via Perl or XS code.
416 You do not need to C<use UNIVERSAL> in order to make these methods
417 available to your program.  This is necessary only if you wish to
418 have C<isa> available as a plain subroutine in the current package.
419
420 =head2 TIEHANDLE now supported
421
422 See L<perltie> for other kinds of tie()s.
423
424 =over
425
426 =item TIEHANDLE classname, LIST
427
428 This is the constructor for the class.  That means it is expected to
429 return an object of some sort. The reference can be used to
430 hold some internal information.
431
432     sub TIEHANDLE {
433         print "<shout>\n";
434         my $i;
435         return bless \$i, shift;
436     }
437
438 =item PRINT this, LIST
439
440 This method will be triggered every time the tied handle is printed to.
441 Beyond its self reference it also expects the list that was passed to
442 the print function.
443
444     sub PRINT {
445         $r = shift;
446         $$r++;
447         return print join( $, => map {uc} @_), $\;
448     }
449
450 =item READ this LIST
451
452 This method will be called when the handle is read from via the C<read>
453 or C<sysread> functions.
454
455     sub READ {
456         $r = shift;
457         my($buf,$len,$offset) = @_;
458         print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
459     }
460
461 =item READLINE this
462
463 This method will be called when the handle is read from. The method
464 should return undef when there is no more data.
465
466     sub READLINE {
467         $r = shift;
468         return "PRINT called $$r times\n"
469     }
470
471 =item GETC this
472
473 This method will be called when the C<getc> function is called.
474
475     sub GETC { print "Don't GETC, Get Perl"; return "a"; }
476
477 =item DESTROY this
478
479 As with the other types of ties, this method will be called when the
480 tied handle is about to be destroyed. This is useful for debugging and
481 possibly for cleaning up.
482
483     sub DESTROY {
484         print "</shout>\n";
485     }
486
487 =back
488
489 =head2 Malloc enhancements
490
491 Four new compilation flags are recognized by malloc.c.  (They have no
492 effect if perl is compiled with system malloc().)
493
494 =over
495
496 =item -DDEBUGGING_MSTATS
497
498 If perl is compiled with C<DEBUGGING_MSTATS> defined, you can print
499 memory statistics at runtime by running Perl thusly:
500
501   env PERL_DEBUG_MSTATS=2 perl your_script_here
502
503 The value of 2 means to print statistics after compilation and on
504 exit; with a value of 1, the statistics ares printed only on exit.
505 (If you want the statistics at an arbitrary time, you'll need to
506 install the optional module Devel::Peek.)
507
508 =item -DEMERGENCY_SBRK
509
510 If this macro is defined, running out of memory need not be a fatal
511 error: a memory pool can allocated by assigning to the special
512 variable C<$^M>.  See L<"$^M">.
513
514 =item -DPACK_MALLOC
515
516 Perl memory allocation is by bucket with sizes close to powers of two.
517 Because of these malloc overhead may be big, especially for data of
518 size exactly a power of two.  If C<PACK_MALLOC> is defined, perl uses
519 a slightly different algorithm for small allocations (up to 64 bytes
520 long), which makes it possible to have overhead down to 1 byte for
521 allocations which are powers of two (and appear quite often).
522
523 Expected memory savings (with 8-byte alignment in C<alignbytes>) is
524 about 20% for typical Perl usage.  Expected slowdown due to additional
525 malloc overhead is in fractions of a percent (hard to measure, because
526 of the effect of saved memory on speed).
527
528 =item -DTWO_POT_OPTIMIZE
529
530 Similarly to C<PACK_MALLOC>, this macro improves allocations of data
531 with size close to a power of two; but this works for big allocations
532 (starting with 16K by default).  Such allocations are typical for big
533 hashes and special-purpose scripts, especially image processing.
534
535 On recent systems, the fact that perl requires 2M from system for 1M
536 allocation will not affect speed of execution, since the tail of such
537 a chunk is not going to be touched (and thus will not require real
538 memory).  However, it may result in a premature out-of-memory error.
539 So if you will be manipulating very large blocks with sizes close to
540 powers of two, it would be wise to define this macro.
541
542 Expected saving of memory is 0-100% (100% in applications which
543 require most memory in such 2**n chunks); expected slowdown is
544 negligible.
545
546 =back
547
548 =head2 Miscellaneous efficiency enhancements
549
550 Functions that have an empty prototype and that do nothing but return
551 a fixed value are now inlined (e.g. C<sub PI () { 3.14159 }>).
552
553 Each unique hash key is only allocated once, no matter how many hashes
554 have an entry with that key.  So even if you have 100 copies of the
555 same hash, the hash keys never have to be reallocated.
556
557 =head1 Pragmata
558
559 Six new pragmatic modules exist:
560
561 =over
562
563 =item use autouse MODULE => qw(sub1 sub2 sub3)
564
565 Defers C<require MODULE> until someone calls one of the specified
566 subroutines (which must be exported by MODULE).  This pragma should be
567 used with caution, and only when necessary.
568
569 =item use blib
570
571 =item use blib 'dir'
572
573 Looks for MakeMaker-like I<'blib'> directory structure starting in
574 I<dir> (or current directory) and working back up to five levels of
575 parent directories.
576
577 Intended for use on command line with B<-M> option as a way of testing
578 arbitrary scripts against an uninstalled version of a package.
579
580 =item use constant NAME => VALUE
581
582 Provides a convenient interface for creating compile-time constants,
583 See L<perlsub/"Constant Functions">.
584
585 =item use locale
586
587 Tells the compiler to enable (or disable) the use of POSIX locales for
588 builtin operations.
589
590 When C<use locale> is in effect, the current LC_CTYPE locale is used
591 for regular expressions and case mapping; LC_COLLATE for string
592 ordering; and LC_NUMERIC for numeric formating in printf and sprintf
593 (but B<not> in print).  LC_NUMERIC is always used in write, since
594 lexical scoping of formats is problematic at best.
595
596 Each C<use locale> or C<no locale> affects statements to the end of
597 the enclosing BLOCK or, if not inside a BLOCK, to the end of the
598 current file.  Locales can be switched and queried with
599 POSIX::setlocale().
600
601 See L<perllocale> for more information.
602
603 =item use ops
604
605 Disable unsafe opcodes, or any named opcodes, when compiling Perl code.
606
607 =item use vmsish
608
609 Enable VMS-specific language features.  Currently, there are three
610 VMS-specific features available: 'status', which makes C<$?> and
611 C<system> return genuine VMS status values instead of emulating POSIX;
612 'exit', which makes C<exit> take a genuine VMS status value instead of
613 assuming that C<exit 1> is an error; and 'time', which makes all times
614 relative to the local time zone, in the VMS tradition.
615
616 =back
617
618 =head1 Modules
619
620 =head2 Required Updates
621
622 Though Perl 5.004 is compatible with almost all modules that work
623 with Perl 5.003, there are a few exceptions:
624
625     Module   Required Version for Perl 5.004
626     ------   -------------------------------
627     Filter   1.12
628     LWP      5.08
629     Tk       Tk400.202 (-w makes noise)
630
631 =head2 Installation directories
632
633 The I<installperl> script now places the Perl source files for
634 extensions in the architecture-specific library directory, which is
635 where the shared libraries for extensions have always been.  This
636 change is intended to allow administrators to keep the Perl 5.004
637 library directory unchanged from a previous version, without running
638 the risk of binary incompatibility between extensions' Perl source and
639 shared libraries.
640
641 =head2 Module information summary
642
643 Brand new modules, arranged by topic rather than strictly
644 alphabetically:
645
646     CPAN                 interface to Comprehensive Perl Archive Network
647     CPAN::FirstTime      create a CPAN configuration file
648     CPAN::Nox            run CPAN while avoiding compiled extensions
649
650     IO.pm                Top-level interface to IO::* classes
651     IO/File.pm           IO::File extension Perl module
652     IO/Handle.pm         IO::Handle extension Perl module
653     IO/Pipe.pm           IO::Pipe extension Perl module
654     IO/Seekable.pm       IO::Seekable extension Perl module
655     IO/Select.pm         IO::Select extension Perl module
656     IO/Socket.pm         IO::Socket extension Perl module
657
658     Opcode.pm            Disable named opcodes when compiling Perl code
659
660     ExtUtils/Embed.pm    Utilities for embedding Perl in C programs
661     ExtUtils/testlib.pm  Fixes up @INC to use just-built extension
662
663     FindBin.pm           Find path of currently executing program
664
665     Class/Template.pm    Structure/member template builder
666     File/stat.pm         Object-oriented wrapper around CORE::stat
667     Net/hostent.pm       Object-oriented wrapper around CORE::gethost*
668     Net/netent.pm        Object-oriented wrapper around CORE::getnet*
669     Net/protoent.pm      Object-oriented wrapper around CORE::getproto*
670     Net/servent.pm       Object-oriented wrapper around CORE::getserv*
671     Time/gmtime.pm       Object-oriented wrapper around CORE::gmtime
672     Time/localtime.pm    Object-oriented wrapper around CORE::localtime
673     Time/tm.pm           Perl implementation of "struct tm" for {gm,local}time
674     User/grent.pm        Object-oriented wrapper around CORE::getgr*
675     User/pwent.pm        Object-oriented wrapper around CORE::getpw*
676
677     Tie/RefHash.pm       Base class for tied hashes with references as keys
678
679     UNIVERSAL.pm         Base class for *ALL* classes
680
681 =head2 Fcntl
682
683 New constants in the existing Fcntl modules are now supported,
684 provided that your operating system happens to support them:
685
686     F_GETOWN F_SETOWN
687     O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
688     O_EXLOCK O_SHLOCK
689
690 These constants are intended for use with the Perl operators sysopen()
691 and fcntl() and the basic database modules like SDBM_File.  For the
692 exact meaning of these and other Fcntl constants please refer to your
693 operating system's documentation for fcntl() and open().
694
695 In addition, the Fcntl module now provides these constants for use
696 with the Perl operator flock():
697
698         LOCK_SH LOCK_EX LOCK_NB LOCK_UN
699
700 These constants are defined in all environments (because where there is
701 no flock() system call, Perl emulates it).  However, for historical
702 reasons, these constants are not exported unless they are explicitly
703 requested with the ":flock" tag (e.g. C<use Fcntl ':flock'>).
704
705 =head2 IO
706
707 The IO module provides a simple mechanism to load all of the IO modules at one
708 go.  Currently this includes:
709
710      IO::Handle
711      IO::Seekable
712      IO::File
713      IO::Pipe
714      IO::Socket
715
716 For more information on any of these modules, please see its
717 respective documentation.
718
719 =head2 Math::Complex
720
721 The Math::Complex module has been totally rewritten, and now supports
722 more operations.  These are overloaded:
723
724      + - * / ** <=> neg ~ abs sqrt exp log sin cos atan2 "" (stringify)
725
726 And these functions are now exported:
727
728     pi i Re Im arg
729     log10 logn ln cbrt root
730     tan
731     csc sec cot
732     asin acos atan
733     acsc asec acot
734     sinh cosh tanh
735     csch sech coth
736     asinh acosh atanh
737     acsch asech acoth
738     cplx cplxe
739
740 =head2 Math::Trig
741
742 This new module provides a simpler interface to parts of Math::Complex for
743 those who need trigonometric functions only for real numbers.
744
745 =head2 DB_File
746
747 There have been quite a few changes made to DB_File. Here are a few of
748 the highlights:
749
750 =over
751
752 =item *
753
754 Fixed a handful of bugs.
755
756 =item *
757
758 By public demand, added support for the standard hash function exists().
759
760 =item *
761
762 Made it compatible with Berkeley DB 1.86.
763
764 =item *
765
766 Made negative subscripts work with RECNO interface.
767
768 =item *
769
770 Changed the default flags from O_RDWR to O_CREAT|O_RDWR and the default
771 mode from 0640 to 0666.
772
773 =item *
774
775 Made DB_File automatically import the open() constants (O_RDWR,
776 O_CREAT etc.) from Fcntl, if available.
777
778 =item *
779
780 Updated documentation.
781
782 =back
783
784 Refer to the HISTORY section in DB_File.pm for a complete list of
785 changes. Everything after DB_File 1.01 has been added since 5.003.
786
787 =head2 Net::Ping
788
789 Major rewrite - support added for both udp echo and real icmp pings.
790
791 =head2 Object-oriented overrides for builtin operators
792
793 Many of the Perl builtins returning lists now have
794 object-oriented overrides.  These are:
795
796     File::stat
797     Net::hostent
798     Net::netent
799     Net::protoent
800     Net::servent
801     Time::gmtime
802     Time::localtime
803     User::grent
804     User::pwent
805
806 For example, you can now say
807
808     use File::stat;
809     use User::pwent;
810     $his = (stat($filename)->st_uid == pwent($whoever)->pw_uid);
811
812 =head1 Utility Changes
813
814 =head2 xsubpp
815
816 =over
817
818 =item C<void> XSUBs now default to returning nothing
819
820 Due to a documentation/implementation bug in previous versions of
821 Perl, XSUBs with a return type of C<void> have actually been
822 returning one value.  Usually that value was the GV for the XSUB,
823 but sometimes it was some already freed or reused value, which would
824 sometimes lead to program failure.
825
826 In Perl 5.004, if an XSUB is declared as returning C<void>, it
827 actually returns no value, i.e. an empty list (though there is a
828 backward-compatibility exception; see below).  If your XSUB really
829 does return an SV, you should give it a return type of C<SV *>.
830
831 For backward compatibility, I<xsubpp> tries to guess whether a
832 C<void> XSUB is really C<void> or if it wants to return an C<SV *>.
833 It does so by examining the text of the XSUB: if I<xsubpp> finds
834 what looks like an assignment to C<ST(0)>, it assumes that the
835 XSUB's return type is really C<SV *>.
836
837 =back
838
839 =head1 C Language API Changes
840
841 =over
842
843 =item C<gv_fetchmethod> and C<perl_call_sv>
844
845 The C<gv_fetchmethod> function finds a method for an object, just like
846 in Perl 5.003.  The GV it returns may be a method cache entry.
847 However, in Perl 5.004, method cache entries are not visible to users;
848 therefore, they can no longer be passed directly to C<perl_call_sv>.
849 Instead, you should use the C<GvCV> macro on the GV to extract its CV,
850 and pass the CV to C<perl_call_sv>.
851
852 The most likely symptom of passing the result of C<gv_fetchmethod> to
853 C<perl_call_sv> is Perl's producing an "Undefined subroutine called"
854 error on the I<second> call to a given method (since there is no cache
855 on the first call).
856
857 =item Extended API for manipulating hashes
858
859 Internal handling of hash keys has changed.  The old hashtable API is
860 still fully supported, and will likely remain so.  The additions to the
861 API allow passing keys as C<SV*>s, so that C<tied> hashes can be given
862 real scalars as keys rather than plain strings (nontied hashes still
863 can only use strings as keys).  New extensions must use the new hash
864 access functions and macros if they wish to use C<SV*> keys.  These
865 additions also make it feasible to manipulate C<HE*>s (hash entries),
866 which can be more efficient.  See L<perlguts> for details.
867
868 =back
869
870 =head1 Documentation Changes
871
872 Many of the base and library pods were updated.  These
873 new pods are included in section 1:
874
875 =over
876
877 =item L<perldelta>
878
879 This document.
880
881 =item L<perllocale>
882
883 Locale support (internationalization and localization).
884
885 =item L<perltoot>
886
887 Tutorial on Perl OO programming.
888
889 =item L<perlapio>
890
891 Perl internal IO abstraction interface.
892
893 =item L<perldebug>
894
895 Although not new, this has been massively updated.
896
897 =item L<perlsec>
898
899 Although not new, this has been massively updated.
900
901 =back
902
903 =head1 New Diagnostics
904
905 Several new conditions will trigger warnings that were
906 silent before.  Some only affect certain platforms.
907 The following new warnings and errors outline these.
908 These messages are classified as follows (listed in
909 increasing order of desperation):
910
911    (W) A warning (optional).
912    (D) A deprecation (optional).
913    (S) A severe warning (mandatory).
914    (F) A fatal error (trappable).
915    (P) An internal error you should never see (trappable).
916    (X) A very fatal error (nontrappable).
917    (A) An alien error message (not generated by Perl).
918
919 =over
920
921 =item "my" variable %s masks earlier declaration in same scope
922
923 (S) A lexical variable has been redeclared in the same scope, effectively
924 eliminating all access to the previous instance.  This is almost always
925 a typographical error.  Note that the earlier variable will still exist
926 until the end of the scope or until all closure referents to it are
927 destroyed.
928
929 =item %s argument is not a HASH element or slice
930
931 (F) The argument to delete() must be either a hash element, such as
932
933     $foo{$bar}
934     $ref->[12]->{"susie"}
935
936 or a hash slice, such as
937
938     @foo{$bar, $baz, $xyzzy}
939     @{$ref->[12]}{"susie", "queue"}
940
941 =item Allocation too large: %lx
942
943 (X) You can't allocate more than 64K on an MS-DOS machine.
944
945 =item Allocation too large
946
947 (F) You can't allocate more than 2^31+"small amount" bytes.
948
949 =item Applying %s to %s will act on scalar(%s)
950
951 (W) The pattern match (//), substitution (s///), and translation (tr///)
952 operators work on scalar values.  If you apply one of them to an array
953 or a hash, it will convert the array or hash to a scalar value -- the
954 length of an array, or the population info of a hash -- and then work on
955 that scalar value.  This is probably not what you meant to do.  See
956 L<perlfunc/grep> and L<perlfunc/map> for alternatives.
957
958 =item Attempt to free nonexistent shared string
959
960 (P) Perl maintains a reference counted internal table of strings to
961 optimize the storage and access of hash keys and other strings.  This
962 indicates someone tried to decrement the reference count of a string
963 that can no longer be found in the table.
964
965 =item Attempt to use reference as lvalue in substr
966
967 (W) You supplied a reference as the first argument to substr() used
968 as an lvalue, which is pretty strange.  Perhaps you forgot to
969 dereference it first.  See L<perlfunc/substr>.
970
971 =item Can't use bareword ("%s") as %s ref while "strict refs" in use
972
973 (F) Only hard references are allowed by "strict refs".  Symbolic references
974 are disallowed.  See L<perlref>.
975
976 =item Cannot resolve method `%s' overloading `%s' in package `%s'
977
978 (P) Internal error trying to resolve overloading specified by a method
979 name (as opposed to a subroutine reference).
980
981 =item Constant subroutine %s redefined
982
983 (S) You redefined a subroutine which had previously been eligible for
984 inlining.  See L<perlsub/"Constant Functions"> for commentary and
985 workarounds.
986
987 =item Constant subroutine %s undefined
988
989 (S) You undefined a subroutine which had previously been eligible for
990 inlining.  See L<perlsub/"Constant Functions"> for commentary and
991 workarounds.
992
993 =item Copy method did not return a reference
994
995 (F) The method which overloads "=" is buggy. See L<overload/Copy Constructor>.
996
997 =item Died
998
999 (F) You passed die() an empty string (the equivalent of C<die "">) or
1000 you called it with no args and both C<$@> and C<$_> were empty.
1001
1002 =item Exiting pseudo-block via %s
1003
1004 (W) You are exiting a rather special block construct (like a sort block or
1005 subroutine) by unconventional means, such as a goto, or a loop control
1006 statement.  See L<perlfunc/sort>.
1007
1008 =item Illegal character %s (carriage return)
1009
1010 (F) A carriage return character was found in the input.  This is an
1011 error, and not a warning, because carriage return characters can break
1012 multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).
1013
1014 =item Illegal switch in PERL5OPT: %s
1015
1016 (X) The PERL5OPT environment variable may only be used to set the
1017 following switches: B<-[DIMUdmw]>.
1018
1019 =item Integer overflow in hex number
1020
1021 (S) The literal hex number you have specified is too big for your
1022 architecture. On a 32-bit architecture the largest hex literal is
1023 0xFFFFFFFF.
1024
1025 =item Integer overflow in octal number
1026
1027 (S) The literal octal number you have specified is too big for your
1028 architecture. On a 32-bit architecture the largest octal literal is
1029 037777777777.
1030
1031 =item internal error: glob failed
1032
1033 (P) Something went wrong with the external program(s) used for C<glob>
1034 and C<E<lt>*.cE<gt>>.  This may mean that your csh (C shell) is
1035 broken.  If so, you should change all of the csh-related variables in
1036 config.sh:  If you have tcsh, make the variables refer to it as if it
1037 were csh (e.g. C<full_csh='/usr/bin/tcsh'>); otherwise, make them all
1038 empty (except that C<d_csh> should be C<'undef'>) so that Perl will
1039 think csh is missing.  In either case, after editing config.sh, run
1040 C<./Configure -S> and rebuild Perl.
1041
1042 =item Name "%s::%s" used only once: possible typo
1043
1044 (W) Typographical errors often show up as unique variable names.
1045 If you had a good reason for having a unique name, then just mention
1046 it again somehow to suppress the message (the C<use vars> pragma is
1047 provided for just this purpose).
1048
1049 =item Null picture in formline
1050
1051 (F) The first argument to formline must be a valid format picture
1052 specification.  It was found to be empty, which probably means you
1053 supplied it an uninitialized value.  See L<perlform>.
1054
1055 =item Offset outside string
1056
1057 (F) You tried to do a read/write/send/recv operation with an offset
1058 pointing outside the buffer.  This is difficult to imagine.
1059 The sole exception to this is that C<sysread()>ing past the buffer
1060 will extend the buffer and zero pad the new area.
1061
1062 =item Out of memory!
1063
1064 (X|F) The malloc() function returned 0, indicating there was insufficient
1065 remaining memory (or virtual memory) to satisfy the request.
1066
1067 The request was judged to be small, so the possibility to trap it
1068 depends on the way Perl was compiled.  By default it is not trappable.
1069 However, if compiled for this, Perl may use the contents of C<$^M> as
1070 an emergency pool after die()ing with this message.  In this case the
1071 error is trappable I<once>.
1072
1073 =item Out of memory during request for %s
1074
1075 (F) The malloc() function returned 0, indicating there was insufficient
1076 remaining memory (or virtual memory) to satisfy the request. However,
1077 the request was judged large enough (compile-time default is 64K), so
1078 a possibility to shut down by trapping this error is granted.
1079
1080 =item Possible attempt to put comments in qw() list
1081
1082 (W) qw() lists contain items separated by whitespace; as with literal
1083 strings, comment characters are not ignored, but are instead treated
1084 as literal data.  (You may have used different delimiters than the
1085 exclamation marks parentheses shown here; braces are also frequently
1086 used.)
1087
1088 You probably wrote something like this:
1089
1090     @list = qw(
1091         a # a comment
1092         b # another comment
1093     );
1094
1095 when you should have written this:
1096
1097     @list = qw(
1098         a
1099         b
1100     );
1101
1102 If you really want comments, build your list the
1103 old-fashioned way, with quotes and commas:
1104
1105     @list = (
1106         'a',    # a comment
1107         'b',    # another comment
1108     );
1109
1110 =item Possible attempt to separate words with commas
1111
1112 (W) qw() lists contain items separated by whitespace; therefore commas
1113 aren't needed to separate the items. (You may have used different
1114 delimiters than the parentheses shown here; braces are also frequently
1115 used.)
1116
1117 You probably wrote something like this:
1118
1119     qw! a, b, c !;
1120
1121 which puts literal commas into some of the list items.  Write it without
1122 commas if you don't want them to appear in your data:
1123
1124     qw! a b c !;
1125
1126 =item Recursive substitution detected
1127
1128 (F) The replacement string of a substitution caused the recursive
1129 execution of that very same substituion.  Perl cannot keep track of
1130 special variables (C<$1>, etc.) under such circumstances.
1131
1132 =item Scalar value @%s{%s} better written as $%s{%s}
1133
1134 (W) You've used a hash slice (indicated by @) to select a single element of
1135 a hash.  Generally it's better to ask for a scalar value (indicated by $).
1136 The difference is that C<$foo{&bar}> always behaves like a scalar, both when
1137 assigning to it and when evaluating its argument, while C<@foo{&bar}> behaves
1138 like a list when you assign to it, and provides a list context to its
1139 subscript, which can do weird things if you're expecting only one subscript.
1140
1141 =item Stub found while resolving method `%s' overloading `%s' in package `%s'
1142
1143 (P) Overloading resolution over @ISA tree may be broken by importing stubs.
1144 Stubs should never be implicitely created, but explicit calls to C<can>
1145 may break this.
1146
1147 =item Too late for "B<-T>" option
1148
1149 (X) The #! line (or local equivalent) in a Perl script contains the
1150 B<-T> option, but Perl was not invoked with B<-T> in its argument
1151 list.  This is an error because, by the time Perl discovers a B<-T> in
1152 a script, it's too late to properly taint everything from the
1153 environment.  So Perl gives up.
1154
1155 =item untie attempted while %d inner references still exist
1156
1157 (W) A copy of the object returned from C<tie> (or C<tied>) was still
1158 valid when C<untie> was called.
1159
1160 =item Unrecognized character %s
1161
1162 (F) The Perl parser has no idea what to do with the specified character
1163 in your Perl script (or eval).  Perhaps you tried to run a compressed
1164 script, a binary program, or a directory as a Perl program.
1165
1166 =item Unsupported function fork
1167
1168 (F) Your version of executable does not support forking.
1169
1170 Note that under some systems, like OS/2, there may be different flavors of
1171 Perl executables, some of which may support fork, some not. Try changing
1172 the name you call Perl by to C<perl_>, C<perl__>, and so on.
1173
1174 =item Use of "$$<digit>" to mean "${$}<digit>" is deprecated
1175
1176 (D) Perl versions before 5.004 misinterpreted any type marker followed
1177 by "$" and a digit.  For example, "$$0" was incorrectly taken to mean
1178 "${$}0" instead of "${$0}".  This bug is (mostly) fixed in Perl 5.004.
1179
1180 However, the developers of Perl 5.004 could not fix this bug completely,
1181 because at least two widely-used modules depend on the old meaning of
1182 "$$0" in a string.  So Perl 5.004 still interprets "$$<digit>" in the
1183 old (broken) way inside strings; but it generates this message as a
1184 warning.  And in Perl 5.005, this special treatment will cease.
1185
1186 =item Value of %s can be "0"; test with defined()
1187
1188 (W) In a conditional expression, you used <HANDLE>, <*> (glob), C<each()>,
1189 or C<readdir()> as a boolean value.  Each of these constructs can return a
1190 value of "0"; that would make the conditional expression false, which is
1191 probably not what you intended.  When using these constructs in conditional
1192 expressions, test their values with the C<defined> operator.
1193
1194 =item Variable "%s" may be unavailable
1195
1196 (W) An inner (nested) I<anonymous> subroutine is inside a I<named>
1197 subroutine, and outside that is another subroutine; and the anonymous
1198 (innermost) subroutine is referencing a lexical variable defined in
1199 the outermost subroutine.  For example:
1200
1201    sub outermost { my $a; sub middle { sub { $a } } }
1202
1203 If the anonymous subroutine is called or referenced (directly or
1204 indirectly) from the outermost subroutine, it will share the variable
1205 as you would expect.  But if the anonymous subroutine is called or
1206 referenced when the outermost subroutine is not active, it will see
1207 the value of the shared variable as it was before and during the
1208 *first* call to the outermost subroutine, which is probably not what
1209 you want.
1210
1211 In these circumstances, it is usually best to make the middle
1212 subroutine anonymous, using the C<sub {}> syntax.  Perl has specific
1213 support for shared variables in nested anonymous subroutines; a named
1214 subroutine in between interferes with this feature.
1215
1216 =item Variable "%s" will not stay shared
1217
1218 (W) An inner (nested) I<named> subroutine is referencing a lexical
1219 variable defined in an outer subroutine.
1220
1221 When the inner subroutine is called, it will probably see the value of
1222 the outer subroutine's variable as it was before and during the
1223 *first* call to the outer subroutine; in this case, after the first
1224 call to the outer subroutine is complete, the inner and outer
1225 subroutines will no longer share a common value for the variable.  In
1226 other words, the variable will no longer be shared.
1227
1228 Furthermore, if the outer subroutine is anonymous and references a
1229 lexical variable outside itself, then the outer and inner subroutines
1230 will I<never> share the given variable.
1231
1232 This problem can usually be solved by making the inner subroutine
1233 anonymous, using the C<sub {}> syntax.  When inner anonymous subs that
1234 reference variables in outer subroutines are called or referenced,
1235 they are automatically rebound to the current values of such
1236 variables.
1237
1238 =item Warning: something's wrong
1239
1240 (W) You passed warn() an empty string (the equivalent of C<warn "">) or
1241 you called it with no args and C<$_> was empty.
1242
1243 =item Ill-formed logical name |%s| in prime_env_iter
1244
1245 (W) A warning peculiar to VMS.  A logical name was encountered when preparing
1246 to iterate over %ENV which violates the syntactic rules governing logical
1247 names.  Since it cannot be translated normally, it is skipped, and will not
1248 appear in %ENV.  This may be a benign occurrence, as some software packages
1249 might directly modify logical name tables and introduce nonstandard names,
1250 or it may indicate that a logical name table has been corrupted.
1251
1252 =item Got an error from DosAllocMem
1253
1254 (P) An error peculiar to OS/2.  Most probably you're using an obsolete
1255 version of Perl, and this should not happen anyway.
1256
1257 =item Malformed PERLLIB_PREFIX
1258
1259 (F) An error peculiar to OS/2.  PERLLIB_PREFIX should be of the form
1260
1261     prefix1;prefix2
1262
1263 or
1264
1265     prefix1 prefix2
1266
1267 with nonempty prefix1 and prefix2.  If C<prefix1> is indeed a prefix
1268 of a builtin library search path, prefix2 is substituted.  The error
1269 may appear if components are not found, or are too long.  See
1270 "PERLLIB_PREFIX" in F<README.os2>.
1271
1272 =item PERL_SH_DIR too long
1273
1274 (F) An error peculiar to OS/2. PERL_SH_DIR is the directory to find the
1275 C<sh>-shell in.  See "PERL_SH_DIR" in F<README.os2>.
1276
1277 =item Process terminated by SIG%s
1278
1279 (W) This is a standard message issued by OS/2 applications, while *nix
1280 applications die in silence.  It is considered a feature of the OS/2
1281 port.  One can easily disable this by appropriate sighandlers, see
1282 L<perlipc/"Signals">.  See also "Process terminated by SIGTERM/SIGINT"
1283 in F<README.os2>.
1284
1285 =back
1286
1287 =head1 BUGS
1288
1289 If you find what you think is a bug, you might check the headers of
1290 recently posted articles in the comp.lang.perl.misc newsgroup.
1291 There may also be information at http://www.perl.com/perl/, the Perl
1292 Home Page.
1293
1294 If you believe you have an unreported bug, please run the B<perlbug>
1295 program included with your release.  Make sure you trim your bug down
1296 to a tiny but sufficient test case.  Your bug report, along with the
1297 output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
1298 analysed by the Perl porting team.
1299
1300 =head1 SEE ALSO
1301
1302 The F<Changes> file for exhaustive details on what changed.
1303
1304 The F<INSTALL> file for how to build Perl.  This file has been
1305 significantly updated for 5.004, so even veteran users should
1306 look through it.
1307
1308 The F<README> file for general stuff.
1309
1310 The F<Copying> file for copyright information.
1311
1312 =head1 HISTORY
1313
1314 Constructed by Tom Christiansen, grabbing material with permission
1315 from innumerable contributors, with kibitzing by more than a few Perl
1316 porters.
1317
1318 Last update: Sat Mar  8 19:51:26 EST 1997