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