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