document compatibility issue with literal list slices and NOTOP
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
CommitLineData
ba8251e8 1=head1 NAME
2
a5222a85 3perldelta - what's new for perl v5.6 (as of v5.005_62)
ba8251e8 4
5=head1 DESCRIPTION
6
f29c64d6 7This is an unsupported alpha release, meant for intrepid Perl developers
8only. The included sources may not even build correctly on some platforms.
9Subscribing to perl5-porters is the best way to monitor and contribute
10to the progress of development releases (see www.perl.org for info).
11
ba8251e8 12This document describes differences between the 5.005 release and this one.
13
14=head1 Incompatible Changes
15
e02fdbd2 16=head2 Perl Source Incompatibilities
17
73b437c8 18Beware that any new warnings that have been added or enhanced old
19warnings are B<not> considered incompatible changes.
a5222a85 20
21Since all new warnings must be explicitly requested via the C<-w>
22switch or the C<warnings> pragma, it is ultimately the programmer's
23responsibility to ensure that warnings are enabled judiciously.
e02fdbd2 24
757edf6f 25=over 4
26
4f25aa18 27=item STOP is a new keyword
28
29In addition to C<BEGIN>, C<INIT> and C<END>, subroutines named
30C<STOP> are now special. They are queued up for execution at the
31end of compilation, and cannot be called directly.
32
08cd8952 33=item Treatment of list slices of undef has changed
34
35When taking a slice of a literal list (as opposed to a slice of
36an array or hash), Perl used to return an empty list if the
37result happened to be composed of all undef values.
38
39The new behavior is to produce an empty list if (and only if)
40the original list was empty. Consider the following example:
41
42 @a = (1,undef,undef,2)[2,1,2];
43
44The old behavior would have resulted in @a having no elements.
45The new behavior ensures it has three undefined elements.
46
47Note in particular that the behavior of slices of the following
48cases remains unchanged:
49
50 @a = ()[1,2];
51 @a = (getpwent)[7,0];
52 @a = (anything_returning_empty_list())[2,1,2];
53 @a = @b[2,1,2];
54 @a = @c{'a','b','c'};
55
56See L<perldata>.
57
757edf6f 58=item Possibly changed pseudo-random number generator
59
60In 5.005_0x and earlier, perl's rand() function used the C library
61rand(3) function. As of 5.005_52, Configure tests for drand48(),
62random(), and rand() (in that order) and picks the first one it finds.
63Perl programs that depend on reproducing a specific set of pseudo-random
c35dd67d 64numbers will now likely produce different output. You can use
65C<sh Configure -Drandfunc=rand> to obtain the old behavior.
757edf6f 66
a5222a85 67=item Hashing function for hash keys has changed
68
69Perl hashes are not order preserving. The apparently random order
70encountered when iterating on the contents of a hash is determined
71by the hashing algorithm used. To improve the distribution of lower
72bits in the hashed value, the algorithm has changed slightly as of
735.005_52. When iterating over hashes, this may yield a random order
74that is B<different> from that of previous versions.
75
76=item C<undef> fails on read only values
77
78Using the C<undef> operator on a readonly value (such as $1) has
79the same effect as assigning C<undef> to the readonly value--it
80throws an exception.
81
82=item Close-on-exec bit may be set on pipe() handles
83
84On systems that support a close-on-exec flag on filehandles, the
85flag will be set for any handles created by pipe(), if that is
86warranted by the value of $^F that may be in effect. Earlier
87versions neglected to set the flag for handles created with
88pipe(). See L<perlfunc/pipe> and L<perlvar/$^F>.
89
90=item Writing C<"$$1"> to mean C<"${$}1"> is unsupported
91
92Perl 5.004 deprecated the interpretation of C<$$1> and
93similar within interpolated strings to mean C<$$ . "1">,
94but still allowed it.
95
96In Perl 5.6 and later, C<"$$1"> always means C<"${$1}">.
97
98=item values(%h) and C<\(%h)> operate on aliases to values, not copies
99
100each(), values() and hashes in a list context return the actual
101values in the hash, instead of copies (as they used to in earlier
102versions). Typical idioms for using these constructs copy the
501fbaef 103returned values, but this can make a significant difference when
a5222a85 104creating references to the returned values.
105
106Keys in the hash are still returned as copies when iterating on
08cd8952 107a hash.
a5222a85 108
109=item vec(EXPR,OFFSET,BITS) enforces powers-of-two BITS
110
08cd8952 111vec() generates a run-time error if the BITS argument is not
a5222a85 112a valid power-of-two integer.
113
114=item Text of some diagnostic output has changed
115
116Most references to internal Perl operations in diagnostics
117have been changed to be more descriptive. This may be an
118issue for programs that may incorrectly rely on the exact
119text of diagnostics for proper functioning.
120
121=item C<%@> has been removed
122
123The undocumented special variable C<%@> that used to accumulate
124"background" errors (such as those that happen in DESTROY())
125has been removed, because it could potentially result in memory
126leaks.
127
39429b3b 128=item Parenthesized not() behaves like a list operator
129
130The C<not> operator now falls under the "if it looks like a function,
131it behaves like a function" rule.
132
133As a result, the parenthesized form can be used with C<grep> and C<map>.
134The following construct used to be a syntax error before, but it works
135as expected now:
136
137 grep not($_), @things;
138
139On the other hand, using C<not> with a literal list slice may not
140work. The following previously allowed construct:
141
142 print not (1,2,3)[0];
143
144needs to written with additional parentheses now:
145
146 print not((1,2,3)[0]);
147
148The behavior remains unaffected when C<not> is not followed by parentheses.
149
757edf6f 150=back
151
e02fdbd2 152=head2 C Source Incompatibilities
153
154=over 4
155
156=item C<PERL_POLLUTE>
157
158Release 5.005 grandfathered old global symbol names by providing preprocessor
87275199 159macros for extension source compatibility. As of release 5.6, these
e02fdbd2 160preprocessor definitions are not available by default. You need to explicitly
14218588 161compile perl with C<-DPERL_POLLUTE> to get these definitions. For
162extensions still using the old symbols, this option can be
2aea4d40 163specified via MakeMaker:
164
14218588 165 perl Makefile.PL POLLUTE=1
e02fdbd2 166
f29c64d6 167=item C<PERL_IMPLICIT_CONTEXT>
168
169This new build option provides a set of macros for all API functions
170such that an implicit interpreter/thread context argument is passed to
171every API function. As a result of this, something like C<sv_setsv(foo,bar)>
2c2d71f5 172amounts to a macro invocation that actually translates to something like
f29c64d6 173C<Perl_sv_setsv(my_perl,foo,bar)>. While this is generally expected
174to not have any significant source compatibility issues, the difference
175between a macro and a real function call will need to be considered.
176
2c2d71f5 177This means that there B<is> a source compatibility issue as a result of
178this if your extensions attempt to use pointers to any of the Perl API
179functions.
180
f29c64d6 181Note that the above issue is not relevant to the default build of
182Perl, whose interfaces continue to match those of prior versions
183(but subject to the other options described here).
184
651a3225 185PERL_IMPLICIT_CONTEXT is automatically enabled whenever Perl is built
186with one of -Dusethreads, -Dusemultiplicity, or both.
f29c64d6 187
2c2d71f5 188See L<perlguts/"The Perl API"> for detailed information on the
189ramifications of building Perl using this option.
190
86058a2d 191=item C<PERL_POLLUTE_MALLOC>
192
14218588 193Enabling Perl's malloc in release 5.005 and earlier caused
86058a2d 194the namespace of system versions of the malloc family of functions to
14218588 195be usurped by the Perl versions, since by default they used the
196same names.
86058a2d 197
198Besides causing problems on platforms that do not allow these functions to
199be cleanly replaced, this also meant that the system versions could not
200be called in programs that used Perl's malloc. Previous versions of Perl
14218588 201have allowed this behaviour to be suppressed with the HIDEMYMALLOC and
86058a2d 202EMBEDMYMALLOC preprocessor definitions.
203
87275199 204As of release 5.6, Perl's malloc family of functions have default names
86058a2d 205distinct from the system versions. You need to explicitly compile perl with
14218588 206C<-DPERL_POLLUTE_MALLOC> to get the older behaviour. HIDEMYMALLOC
207and EMBEDMYMALLOC have no effect, since the behaviour they enabled is now
86058a2d 208the default.
209
210Note that these functions do B<not> constitute Perl's memory allocation API.
211See L<perlguts/"Memory Allocation"> for further information about that.
212
e02fdbd2 213=back
214
cceca5ed 215=head2 Compatible C Source API Changes
216
217=over
218
219=item C<PATCHLEVEL> is now C<PERL_VERSION>
220
14218588 221The cpp macros C<PERL_REVISION>, C<PERL_VERSION>, and C<PERL_SUBVERSION>
cceca5ed 222are now available by default from perl.h, and reflect the base revision,
14218588 223patchlevel, and subversion respectively. C<PERL_REVISION> had no
cceca5ed 224prior equivalent, while C<PERL_VERSION> and C<PERL_SUBVERSION> were
225previously available as C<PATCHLEVEL> and C<SUBVERSION>.
226
14218588 227The new names cause less pollution of the B<cpp> namespace and reflect what
cceca5ed 228the numbers have come to stand for in common practice. For compatibility,
14218588 229the old names are still supported when F<patchlevel.h> is explicitly
cceca5ed 230included (as required before), so there is no source incompatibility
14218588 231from the change.
cceca5ed 232
a5222a85 233=item Support for C++ exceptions
234
235change#3386, also needs perlguts documentation
236[TODO - Chip Salzenberg <chip@perlsupport.com>]
237
cceca5ed 238=back
239
e02fdbd2 240=head2 Binary Incompatibilities
241
9c107f78 242The default build of this release is binary compatible with the 5.005
243release or its maintenance versions.
f29c64d6 244
245The usethreads or usemultiplicity builds are B<not> binary compatible
246with the corresponding builds in 5.005.
e02fdbd2 247
a5222a85 248=head1 Installation and Configuration Improvements
249
250=head2 New Configure flags
251
252The following new flags may be enabled on the Configure command line
253by running Configure with C<-Dflag>.
254
255 usemultiplicity
67d3893f 256
257 uselongdouble
a5222a85 258 usemorebits
259 uselargefiles
a5222a85 260
67d3893f 261=head2 -Dusethreads and -Duse64bits now more daring
262
263The Configure options enabling the use of threads and the use of
26464-bitness are now more daring in the sense that they no more have
265an explicit list of operating systems of known threads/64-bit
266capabilities. In other words: if your operating system has the
267necessary APIs, you should be able just to go ahead and use them.
268See also L<"64-bit support">.
269
270=head2 Long Doubles
271
272Some platforms have "long doubles", floating point numbers of even
437784d6 273larger range than ordinary "doubles". To enable using long doubles for
67d3893f 274Perl's scalars, use -Duselongdouble.
275
276=head2 -Dusemorebits
277
278You can enable both -Duse64bits and -Dlongdouble by -Dusemorebits.
279See also L<"64-bit support">.
280
281=head2 -Duselargefiles
282
283Some platforms support large files, files larger than two gigabytes.
284See L<"Large file support"> for more information.
a5222a85 285
286=head2 installusrbinperl
287
288You can use "Configure -Uinstallusrbinperl" which causes installperl
289to skip installing perl also as /usr/bin/perl. This is useful if you
290prefer not to modify /usr/bin for some reason or another but harmful
291because many scripts assume to find Perl in /usr/bin/perl.
292
293=head2 SOCKS support
294
295You can use "Configure -Dusesocks" which causes Perl to probe
c35dd67d 296for the SOCKS (v5, not v4) proxy protocol library,
297http://www.socks.nec.com/
a5222a85 298
299=head2 C<-A> flag
300
301You can "post-edit" the Configure variables using the Configure C<-A>
302flag. The editing happens immediately after the platform specific
303hints files have been processed but before the actual configuration
304process starts. Run C<Configure -h> to find out the full C<-A> syntax.
305
c35dd67d 306=head2 Enhanced Installation Directories
67d3893f 307
c35dd67d 308The installation structure has been enriched to improve the support for
309maintaining multiple versions of perl, to provide locations for
310vendor-supplied modules and scripts, and to ease maintenance of
311locally-added modules and scripts. See the section on Installation
312Directories in the INSTALL file for complete details. For most users
313building and installing from source, the defaults should be fine.
67d3893f 314
ba8251e8 315=head1 Core Changes
316
9d73390d 317=head2 Unicode and UTF-8 support
318
319Perl can optionally use UTF-8 as its internal representation for character
a5222a85 320strings. The C<utf8> pragma enables this support in the current lexical
9d73390d 321scope. See L<utf8> for more information.
322
323=head2 Lexically scoped warning categories
324
325You can now control the granularity of warnings emitted by perl at a finer
4438c4b7 326level using the C<use warnings> pragma. See L<warnings> and L<perllexwarn>
0453d815 327for details.
9d73390d 328
a5222a85 329=head2 Lvalue subroutines
330
331WARNING: This is an experimental feature.
332
333change#4081
334[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>,
335Tuomas Lukka <lukka@fas.harvard.edu>)]
336
337=head2 "our" declarations
338
339An "our" declaration introduces a value that can be best understood
340as a lexically scoped symbolic alias to a global variable in the
341current package. This is mostly useful as an alternative to the
342C<vars> pragma, but also provides the opportunity to introduce
343typing and other attributes for such variables. See L<perlfunc/our>.
344
345=head2 Weak references
346
347WARNING: This is an experimental feature.
348
349change#3385, also need perlguts documentation
350
351[TODO - Tuomas Lukka <lukka@fas.harvard.edu>]
352
becf2bd3 353=head2 File globbing implemented internally
354
355WARNING: This is currently an experimental feature. Interfaces and
356implementation are likely to change.
357
52bb0670 358Perl now uses the File::Glob implementation of the glob() operator
359automatically. This avoids using an external csh process and the
360problems associated with it.
becf2bd3 361
5fdc711f 362=head2 Binary numbers supported
363
4f19785b 364Binary numbers are now supported as literals, in s?printf formats, and
365C<oct()>:
366
14218588 367 $answer = 0b101010;
368 printf "The answer is: %b\n", oct("0b101010");
4f19785b 369
a5222a85 370=head2 Some arrows may be omitted in calls through references
371
372Perl now allows the arrow to be omitted in many constructs
373involving subroutine calls through references. For example,
374C<$foo[10]->('foo')> may now be written C<$foo[10]('foo')>.
375This is rather similar to how the arrow may be omitted from
376C<$foo[10]->{'foo'}>. Note however, that the arrow is still
377required for C<foo(10)->('bar')>.
378
5fdc711f 379=head2 syswrite() ease-of-use
380
a5222a85 381The length argument of C<syswrite()> has become optional.
382
383=head2 Filehandles can be autovivified
384
2c8ac474 385Similar to how constructs such as C<$x->[0]> autovivify a reference,
386open() now autovivifies a filehandle if the first argument is an
387uninitialized variable. This allows the constructs C<open(my $fh, ...)> and
388C<open(local $fh,...)> to be used to create filehandles that will
389conveniently be closed automatically when the scope ends, provided there
390are no other references to them. This largely eliminates the need for
391typeglobs when opening filehandles that must be passed around, as in the
392following example:
a5222a85 393
394 sub myopen {
395 open my $fh, "@_"
396 or die "Can't open '@_': $!";
397 return $fh;
398 }
399
400 {
401 my $f = myopen("</etc/motd");
402 print <$f>;
403 # $f implicitly closed here
404 }
405
406[TODO - this idiom needs more pod penetration]
6c67e1bb 407
5fdc711f 408=head2 64-bit support
409
9c107f78 410All platforms that have 64-bit integers either (a) natively as longs
411or ints (b) via special compiler flags (c) using long long are able to
412use "quads" (64-integers) as follows:
413
414=over 4
415
a5222a85 416=item *
417
418constants (decimal, hexadecimal, octal, binary) in the code
419
420=item *
9c107f78 421
a5222a85 422arguments to oct() and hex()
9c107f78 423
a5222a85 424=item *
425
426arguments to print(), printf() and sprintf() (flag prefixes ll, L, q)
427
428=item *
9c107f78 429
a5222a85 430printed as such
9c107f78 431
a5222a85 432=item *
433
434pack() and unpack() "q" and "Q" formats
435
436=item *
437
438in basic arithmetics: + - * / %
439
440=item *
1fad5d67 441
a5222a85 442vec() (but see the below note about bit arithmetics)
9c107f78 443
444=back
445
446Note that unless you have the case (a) you will have to configure
447and compile Perl using the -Duse64bits Configure flag.
448
3175b8cd 449Unfortunately bit arithmetics (&, |, ^, ~, <<, >>) for numbers are not
45064-bit clean, they are explictly forced to be 32-bit. Bit arithmetics
451for bit vectors (created by vec()) are not limited in their width.
d0ba1bd2 452
2d4389e4 453Last but not least: note that due to Perl's habit of always using
d0ba1bd2 454floating point numbers the quads are still not true integers.
455When quads overflow their limits (0...18_446_744_073_709_551_615 unsigned,
456-9_223_372_036_854_775_808...9_223_372_036_854_775_807 signed), they
457are silently promoted to floating point numbers, after which they will
458start losing precision (their lower digits).
2d4389e4 459
460=head2 Large file support
461
462If you have filesystems that support "large files" (files larger than
aa855319 4632 gigabytes), you may now also be able to create and access them from
249b38c6 464Perl. You have to use Configure -Duselargefiles. Turning on the
465large file support turns on also the 64-bit support, for obvious reasons.
2d4389e4 466
eed7fde4 467Note that in addition to requiring a proper file system to do large
468files you may also need to adjust your per-process (or your
469per-system, or per-process-group, or per-user-group) maximum filesize
470limits before running Perl scripts that try to handle large files,
471especially if you intend to write such files.
472
473Finally, in addition to your process/process group maximum filesize
474limits, you may have quota limits on your filesystems that stop you
475(your user id or your user group id) from using large files.
476
477Adjusting your process/user/group/file system/operating system limits
478is outside the scope of Perl core language. For process limits, you
479may try increasing the limits using your shell's limits/limit/ulimit
480command before running Perl. The BSD::Resource extension (not
481included with the standard Perl distribution) may also be of use, it
482offers the getrlimit/setrlimit interface that can be used to adjust
483process resource usage limits, including the maximum filesize limit.
475d79b5 484
aa855319 485=head2 Long doubles
486
487In some systems you may be able to use long doubles to enhance the
488range of precision of your double precision floating point numbers
489(that is, Perl's numbers). Use Configure -Duselongdouble to enable
490this support (if it is available).
491
492=head2 "more bits"
493
494You can Configure -Dusemorebits to turn on both the 64-bit support
495and the long double support.
09bef843 496
43481408 497=head2 Enhanced support for sort() subroutines
498
499Perl subroutines with a prototype of C<($$)> and XSUBs in general can
500now be used as sort subroutines. In either case, the two elements to
501be compared as passed as normal parameters in @_. See L<perlfunc/sort>.
502
503For unprototyped sort subroutines, the historical behavior of passing
504the elements to be compared as the global variables $a and $b remains
505unchanged.
506
62c18ce2 507=head2 Better syntax checks on parenthesized unary operators
508
509Expressions such as:
510
14218588 511 print defined(&foo,&bar,&baz);
512 print uc("foo","bar","baz");
513 undef($foo,&bar);
62c18ce2 514
7711098a 515used to be accidentally allowed in earlier versions, and produced
14218588 516unpredictable behaviour. Some produced ancillary warnings
517when used in this way; others silently did the wrong thing.
62c18ce2 518
519The parenthesized forms of most unary operators that expect a single
14218588 520argument now ensure that they are not called with more than one
521argument, making the cases shown above syntax errors. The usual
522behaviour of:
62c18ce2 523
14218588 524 print defined &foo, &bar, &baz;
525 print uc "foo", "bar", "baz";
526 undef $foo, &bar;
62c18ce2 527
528remains unchanged. See L<perlop>.
529
3e3318e7 530=head2 POSIX character class syntax [: :] supported
531
532For example to match alphabetic characters use /[[:alpha:]]/.
533See L<perlre> for details.
534
5a929a98 535=head2 Improved C<qw//> operator
8127e0e3 536
26ef7447 537The C<qw//> operator is now evaluated at compile time into a true list
538instead of being replaced with a run time call to C<split()>. This
14218588 539removes the confusing misbehaviour of C<qw//> in scalar context, which
540had inherited that behaviour from split().
26ef7447 541
542Thus:
543
544 $foo = ($bar) = qw(a b c); print "$foo|$bar\n";
545
546now correctly prints "3|a", instead of "2|a".
8127e0e3 547
5a929a98 548=head2 pack() format 'Z' supported
549
550The new format type 'Z' is useful for packing and unpacking null-terminated
551strings. See L<perlfunc/"pack">.
552
4d0c1c44 553=head2 pack() format modifier '!' supported
ee3907e2 554
14218588 555The new format type modifier '!' is useful for packing and unpacking
ee3907e2 556native shorts, ints, and longs. See L<perlfunc/"pack">.
557
f29c64d6 558=head2 pack() and unpack() support counted strings
559
a5222a85 560The template character '/' can be used to specify a counted string
f29c64d6 561type to be packed or unpacked. See L<perlfunc/"pack">.
562
a5222a85 563=head2 Comments in pack() templates
564
565The '#' character in a template introduces a comment up to
566end of the line. This facilitates documentation of pack()
567templates.
568
2b92dfce 569=head2 $^X variables may now have names longer than one character
570
571Formerly, $^X was synonymous with ${"\cX"}, but $^XY was a syntax
572error. Now variable names that begin with a control character may be
573arbitrarily long. However, for compatibility reasons, these variables
574I<must> be written with explicit braces, as C<${^XY}> for example.
14218588 575C<${^XYZ}> is synonymous with ${"\cXYZ"}. Variable names with more
2b92dfce 576than one control character, such as C<${^XY^Z}>, are illegal.
577
14218588 578The old syntax has not changed. As before, `^X' may be either a
579literal control-X character or the two-character sequence `caret' plus
580`X'. When braces are omitted, the variable name stops after the
2b92dfce 581control character. Thus C<"$^XYZ"> continues to be synonymous with
7711098a 582C<$^X . "YZ"> as before.
2b92dfce 583
584As before, lexical variables may not have names beginning with control
585characters. As before, variables whose names begin with a control
14218588 586character are always forced to be in package `main'. All such variables
587are reserved for future extensions, except those that begin with
09bef843 588C<^_>, which may be used by user programs and are guaranteed not to
14218588 589acquire special meaning in any future version of Perl.
2b92dfce 590
09bef843 591=head2 C<use attrs> implicit in subroutine attributes
592
593Formerly, if you wanted to mark a subroutine as being a method call or
594as requiring an automatic lock() when it is entered, you had to declare
595that with a C<use attrs> pragma in the body of the subroutine.
596That can now be accomplished with a declaration syntax, like this:
597
598 sub mymethod : locked, method ;
599 ...
600 sub mymethod : locked, method {
601 ...
602 }
603
604F<AutoSplit.pm> and F<SelfLoader.pm> have been updated to keep the attributes
605with the stubs they provide. See L<attributes>.
606
a5222a85 607=head2 Regular expression improvements
608
609change#2827,2373,2372,2365,1813,1800,4112,4158,4215,4301
610[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
611
612=head2 Overloading improvements
613
614change#2150
615[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
616
617=head2 open() with more than two arguments
618
619[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
620
621=head2 Support for interpolating named characters
622
623change#4052
624[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
625
08cd8952 626=head2 Experimental support for user-hooks in @INC
a5222a85 627
628[TODO - Ken Fox <kfox@ford.com>]
629
630=head2 C<require> and C<do> may be overridden
631
632C<require> and C<do 'file'> operations may be overridden locally
633by importing subroutines of the same name into the current package
634(or globally by importing them into the CORE::GLOBAL:: namespace).
635Overriding C<require> will also affect C<use>, provided the override
636is visible at compile-time.
637See L<perlsub/"Overriding Built-in Functions">.
638
639=head2 New variable $^C reflects C<-c> switch
640
08cd8952 641C<$^C> has a boolean value that reflects whether perl is being run
a5222a85 642in compile-only mode (i.e. via the C<-c> switch). Since
643BEGIN blocks are executed under such conditions, this variable
644enables perl code to determine whether actions that make sense
645only during normal running are warranted. See L<perlvar>.
646
4f25aa18 647=head2 STOP blocks
648
649Arbitrary code can be queued for execution when Perl has finished
650parsing the program (i.e. when the compile phase ends) using STOP
651blocks. These behave similar to END blocks, except for being
652called at the end of compilation rather than at the end of execution.
653
a5222a85 654=head2 Optional Y2K warnings
655
656If Perl is built with the cpp macro C<PERL_Y2KWARN> defined,
657it emits optional warnings when concatenating the number 19
658with another number.
659
660This behavior must be specifically enabled when running Configure.
661See L<INSTALL> and L<README.Y2K>.
662
fbad3eb5 663=head1 Significant bug fixes
664
665=head2 E<lt>HANDLEE<gt> on empty files
666
667With C<$/> set to C<undef>, slurping an empty file returns a string of
14218588 668zero length (instead of C<undef>, as it used to) the first time the
669HANDLE is read. Further reads yield C<undef>.
fbad3eb5 670
671This means that the following will append "foo" to an empty file (it used
14218588 672to do nothing):
fbad3eb5 673
674 perl -0777 -pi -e 's/^/foo/' empty_file
675
14218588 676The behaviour of:
fbad3eb5 677
678 perl -pi -e 's/^/foo/' empty_file
679
680is unchanged (it continues to leave the file empty).
681
0244c3a4 682=head2 C<eval '...'> improvements
683
684Line numbers (as reflected by caller() and most diagnostics) within
685C<eval '...'> were often incorrect when here documents were involved.
686This has been corrected.
687
688Lexical lookups for variables appearing in C<eval '...'> within
689functions that were themselves called within an C<eval '...'> were
14218588 690searching the wrong place for lexicals. The lexical search now
691correctly ends at the subroutine's block boundary.
0244c3a4 692
693Parsing of here documents used to be flawed when they appeared as
694the replacement expression in C<eval 's/.../.../e'>. This has
695been fixed.
696
a5222a85 697=head2 All compilation errors are true errors
698
699Some "errors" encountered at compile time were by neccessity
700generated as warnings followed by eventual termination of the
701program. This enabled more such errors to be reported in a
702single run, rather than causing a hard stop at the first error
703that was encountered.
704
705The mechanism for reporting such errors has been reimplemented
706to queue compile-time errors and report them at the end of the
707compilation as true errors rather than as warnings. This fixes
08cd8952 708cases where error messages leaked through in the form of warnings
709when code was compiled at run time using C<eval STRING>, and
710also allows such errors to be reliably trapped using __DIE__ hooks.
a5222a85 711
45bc9206 712=head2 Automatic flushing of output buffers
713
14218588 714fork(), exec(), system(), qx//, and pipe open()s now flush buffers
715of all files opened for output when the operation
716was attempted. This mostly eliminates confusing
45bc9206 717buffering mishaps suffered by users unaware of how Perl internally
14218588 718handles I/O.
45bc9206 719
af8c498a 720=head2 Better diagnostics on meaningless filehandle operations
721
722Constructs such as C<open(E<lt>FHE<gt>)> and C<close(E<lt>FHE<gt>)>
723are compile time errors. Attempting to read from filehandles that
724were opened only for writing will now produce warnings (just as
725writing to read-only filehandles does).
726
a5222a85 727=head2 Where possible, buffered data discarded from duped input filehandle
728
729C<open(NEW, "E<lt>&OLD")> now attempts to discard any data that
730was previously read and buffered in C<OLD> before duping the handle.
731On platforms where doing this is allowed, the next read operation
732on C<NEW> will return the same data as the corresponding operation
733on C<OLD>. Formerly, it would have returned the data from the start
734of the following disk block instead.
735
736=head2 system(), backticks and pipe open now reflect exec() failure
737
738On Unix and similar platforms, system(), qx() and open(FOO, "cmd |")
739etc., are implemented via fork() and exec(). When the underlying
740exec() fails, earlier versions did not report the error properly,
741since the exec() happened to be in a different process.
742
743The child process now communicates with the parent about the
437784d6 744error in launching the external command, which allows these
a5222a85 745constructs to return with their usual error value and set $!.
746
747=head2 Implicitly closed filehandles are safer
748
749Sometimes implicitly closed filehandles (as when they are localized,
750and Perl automatically closes them on exiting the scope) could
751inadvertently set $? or $!. This has been corrected.
752
753=head2 C<(\$)> prototype and C<$foo{a}>
754
755An scalar reference prototype now correctly allows a hash or
756array element in that slot.
757
758=head2 Pseudo-hashes work better
759
760Dereferencing some types of reference values in a pseudo-hash,
761such as C<$ph->{foo}[1]>, was accidentally disallowed. This has
762been corrected.
763
764When applied to a pseudo-hash element, exists() now reports whether
765the specified value exists, not merely if the key is valid.
766
767=head2 C<goto &sub> and AUTOLOAD
768
08cd8952 769The C<goto &sub> construct works correctly when C<&sub> happens
a5222a85 770to be autoloaded.
771
772=head2 C<-bareword> allowed under C<use integer>
773
774The autoquoting of barewords preceded by C<-> did not work
775in prior versions when the C<integer> pragma was enabled.
776This has been fixed.
777
778=head2 Boolean assignment operators are legal lvalues
779
780Constructs such as C<($a ||= 2) += 1> are now allowed.
781
782=head2 C<sort $coderef @foo> allowed
783
784sort() did not accept a subroutine reference as the comparison
08cd8952 785function in earlier versions. This is now permitted.
a5222a85 786
787=head2 Failures in DESTROY()
788
789When code in a destructor threw an exception, it went unnoticed
790in earlier versions of Perl, unless someone happened to be
791looking in $@ just after the point the destructor happened to
792run. Such failures are now visible as warnings when warnings are
793enabled.
794
795=head2 Locale bugs fixed
54195c32 796
437784d6 797printf() and sprintf() previously reset the numeric locale
67d3893f 798back to the default "C" locale. This has been fixed.
799
800Numbers formatted according to the local numeric locale
801(such as using a decimal comma instead of a decimal dot) caused
802"isn't numeric" warnings, even while the operations accessing
803those numbers produced correct results. The warnings are gone.
54195c32 804
a5222a85 805=head2 Memory leaks
806
807The C<eval 'return sub {...}'> construct could sometimes leak
808memory. This has been fixed.
809
810Operations that aren't filehandle constructors used to leak memory
811when used on invalid filehandles. This has been fixed.
812
813Constructs that modified C<@_> could fail to deallocate values
814in C<@_> and thus leak memory. This has been corrected.
815
816=head2 Spurious subroutine stubs after failed subroutine calls
817
818Perl could sometimes create empty subroutine stubs when a
819subroutine was not found in the package. Such cases stopped
820later method lookups from progressing into base packages.
821This has been corrected.
822
823=head2 Consistent numeric conversions
824
825change#3378,3318
826[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
827
828=head2 Taint failures under C<-U>
829
830When running in unsafe mode, taint violations could sometimes
831cause silent failures. This has been fixed.
832
833=head2 END blocks and the C<-c> switch
834
835Prior versions used to run BEGIN B<and> END blocks when Perl was
836run in compile-only mode. Since this is typically not the expected
08cd8952 837behavior, END blocks are not executed anymore when the C<-c> switch
a5222a85 838is used.
839
4f25aa18 840See L<STOP blocks> for how to run things when the compile phase ends.
a5222a85 841
842=head2 Potential to leak DATA filehandles
843
844Using the C<__DATA__> token creates an implicit filehandle to
845the file that contains the token. It is the program's
846responsibility to close it when it is done reading from it.
847
848This caveat is now better explained in the documentation.
849See L<perldata>.
850
851=head2 Diagnostics follow STDERR
852
853Diagnostic output now goes to whichever file the C<STDERR> handle
854is pointing at, instead of always going to the underlying C runtime
855library's C<stderr>.
856
857=head2 Other fixes for better diagnostics
858
437784d6 859Line numbers are no longer suppressed (under most likely circumstances)
a5222a85 860during the global destruction phase.
861
862Diagnostics emitted from code running in threads other than the main
863thread are now accompanied by the thread ID.
864
865Embedded null characters in diagnostics now actually show up. They
866used to truncate the message in prior versions.
867
868$foo::a and $foo::b are now exempt from "possible typo" warnings only
869if sort() is encountered in package foo.
870
501fbaef 871Unrecognized alphabetic escapes encountered when parsing quote
a5222a85 872constructs now generate a warning, since they may take on new
873semantics in later versions of Perl.
874
875=head1 Performance enhancements
876
877=head2 Simple sort() using { $a <=> $b } and the like are optimized
878
08cd8952 879Many common sort() operations using a simple inlined block are now
a5222a85 880optimized for faster performance.
881
882=head2 Optimized assignments to lexical variables
883
884Certain operations in the RHS of assignment statements have been
885optimized to directly set the lexical variable on the LHS,
886eliminating redundant copying overheads.
887
888=head2 Method lookups optimized
889
890[TODO - Chip Salzenberg <chip@perlsupport.com>]
891
892=head2 Faster mechanism to invoke XSUBs
893
894change#4044,4125
895[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
896
897=head2 Perl_malloc() improvements
898
899change#4237
900[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
901
902=head2 Faster subroutine calls
903
904Minor changes in how subroutine calls are handled internally
905provide marginal improvements in performance.
906
907=head1 Platform specific changes
908
909=head2 Additional supported platforms
ba8251e8 910
5fdc711f 911=over 4
912
913=item *
914
6c67e1bb 915VM/ESA is now supported.
916
5fdc711f 917=item *
918
ee3907e2 919Siemens BS2000 is now supported under the POSIX Shell.
920
921=item *
922
2bb14304 923The Mach CThreads (NEXTSTEP, OPENSTEP) are now supported by the Thread
924extension.
6c67e1bb 925
5fdc711f 926=item *
927
ee3907e2 928GNU/Hurd is now supported.
6c67e1bb 929
00ad96e1 930=item *
931
932Rhapsody is now supported.
933
27806c82 934=item *
935
936EPOC is is now supported (on Psion 5).
937
5fdc711f 938=back
939
a5222a85 940=head2 DOS
941
d524f05e 942=over 4
943
944=item *
945
946Perl now works with djgpp 2.02 (and 2.03 alpha).
947
948=item *
949
950Environment variable names are not converted to uppercase any more.
951
952=item *
953
954Wrong exit code from backticks now fixed.
955
956=item *
957
958This port is still using its own builtin globbing.
959
960=back
a5222a85 961
962=head2 OS/2
963
964[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
965
966=head2 VMS
967
968[TODO - Charles Bailey <bailey@newman.upenn.edu>]
969
970=head2 Win32
971
972Site library searches failed to look for ".../site/5.XXX/lib"
973if ".../site/5.XXXYY/lib" wasn't found. This has been corrected.
974
975When given a pathname that consists only of a drivename, such
976as C<A:>, opendir() and stat() now use the current working
977directory for the drive rather than the drive root.
978
979The builtin XSUB functions in the Win32:: namespace are
980documented. See L<Win32>.
981
982$^X now contains the full path name of the running executable.
983
984A Win32::GetLongPathName() function is provided to complement
985Win32::GetFullPathName() and Win32::GetShortPathName(). See L<Win32>.
986
987POSIX::uname() is supported.
988
989system(1,...) now returns true process IDs rather than process
990handles. kill() accepts any real process id, rather than strictly
991return values from system(1,...).
992
993The C<Shell> module is supported.
994
883d36a6 995Rudimentary support for building under command.com in Windows 95
996has been added.
997
a5222a85 998[TODO - GSAR]
999
6c67e1bb 1000=head1 New tests
1001
1002=over 4
1003
09bef843 1004=item lib/attrs
1005
1006Compatibility tests for C<sub : attrs> vs the older C<use attrs>.
1007
1008=item lib/io_const
6c67e1bb 1009
1010IO constants (SEEK_*, _IO*).
14218588 1011
09bef843 1012=item lib/io_dir
6c67e1bb 1013
1014Directory-related IO methods (new, read, close, rewind, tied delete).
1015
09bef843 1016=item lib/io_multihomed
6c67e1bb 1017
1018INET sockets with multi-homed hosts.
1019
09bef843 1020=item lib/io_poll
6c67e1bb 1021
1022IO poll().
1023
09bef843 1024=item lib/io_unix
6c67e1bb 1025
1026UNIX sockets.
1027
09bef843 1028=item op/attrs
1029
1030Regression tests for C<my ($x,@y,%z) : attrs> and <sub : attrs>.
1031
6c67e1bb 1032=item op/filetest
1033
1034File test operators.
1035
1036=item op/lex_assign
1037
5fdc711f 1038Verify operations that access pad objects (lexicals and temporaries).
6c67e1bb 1039
1040=back
e02fdbd2 1041
ba8251e8 1042=head1 Modules and Pragmata
1043
3e8c4fa0 1044=head2 Modules
1045
b7d8191e 1046=over 4
1047
09bef843 1048=item attributes
1049
1050While used internally by Perl as a pragma, this module also
1051provides a way to fetch subroutine and variable attributes.
1052See L<attributes>.
1053
a5222a85 1054=item B
1055
501fbaef 1056The Perl Compiler suite has been extensively reworked for this
1057release.
1058
a5222a85 1059[TODO - Vishal Bhatia <vishal@gol.com>,
1060Nick Ing-Simmons <nick@ni-s.u-net.com>]
1061
f29c64d6 1062=item ByteLoader
1063
a5222a85 1064The ByteLoader is a dedicated extension to generate and run
f29c64d6 1065Perl bytecode. See L<ByteLoader>.
1066
a5222a85 1067=item constant
1068
1069References can now be used. See L<constant>.
1070
1071=item charnames
1072
1073change#4052
1074[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
1075
1076=item Data::Dumper
1077
1078A C<Maxdepth> setting can be specified to avoid venturing
73b437c8 1079too deeply into deep data structures. See L<Data::Dumper>.
a5222a85 1080
1081Dumping C<qr//> objects works correctly.
1082
1083=item DB
1084
1085C<DB> is an experimental module that exposes a clean abstraction
1086to Perl's debugging API.
1087
1088=item DB_File
1089
1090[TODO - Paul Marquess <paul.marquess@bt.com>]
1091
f29c64d6 1092=item Devel::DProf
1093
9e107c59 1094Devel::DProf, a Perl source code profiler has been added. See
1095L<Devel::DProf> and L<dprofpp>.
f29c64d6 1096
b7d8191e 1097=item Dumpvalue
1098
437784d6 1099The Dumpvalue module provides screen dumps of Perl data.
b7d8191e 1100
1101=item Benchmark
1102
54e82ce5 1103Overall, Benchmark results exhibit lower average error and better timing
1104accuracy.
1105
868cb350 1106You can now run tests for I<n> seconds instead of guessing the right
14218588 1107number of tests to run: e.g. timethese(-5, ...) will run each
1108code for at least 5 CPU seconds. Zero as the "number of repetitions"
155776c0 1109means "for at least 3 CPU seconds". The output format has also
14218588 1110changed. For example:
155776c0 1111
54e82ce5 1112 use Benchmark;$x=3;timethese(-5,{a=>sub{$x*$x},b=>sub{$x**2}})
155776c0 1113
1114will now output something like this:
1115
54e82ce5 1116 Benchmark: running a, b, each for at least 5 CPU seconds...
1117 a: 5 wallclock secs ( 5.77 usr + 0.00 sys = 5.77 CPU) @ 200551.91/s (n=1156516)
1118 b: 4 wallclock secs ( 5.00 usr + 0.02 sys = 5.02 CPU) @ 159605.18/s (n=800686)
155776c0 1119
1120New features: "each for at least N CPU seconds...", "wallclock secs",
1121and the "@ operations/CPU second (n=operations)".
b7d8191e 1122
54e82ce5 1123timethese() now returns a reference to a hash of Benchmark objects containing
1124the test results, keyed on the names of the tests.
1125
1126timethis() now returns the iterations field in the Benchmark result object
1127instead of 0.
1128
1129timethese(), timethis(), and the new cmpthese() (see below) can also take
1130a format specifier of 'none' to suppress output.
1131
1132A new function countit() is just like timeit() except that it takes a
1133TIME instead of a COUNT.
1134
1135A new function cmpthese() prints a chart comparing the results of each test
1136returned from a timethese() call. For each possible pair of tests, the
1137percentage speed difference (iters/sec or seconds/iter) is shown.
1138
1139For other details, see L<Benchmark>.
a5222a85 1140
f505c983 1141=item Devel::Peek
1142
1143The Devel::Peek module provides access to the internal representation
14218588 1144of Perl variables and data. It is a data debugging tool for the XS programmer.
f505c983 1145
a5222a85 1146=item ExtUtils::MakeMaker
1147
1148change#4135, also needs docs in module pod
1149[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
1150
b7d8191e 1151=item Fcntl
1152
1153More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for
14218588 1154large (more than 4G) file access (64-bit support is not yet
b7d8191e 1155working, though, so no need to get overly excited), Free/Net/OpenBSD
1156locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and
1157O_ACCMODE: the mask of O_RDONLY, O_WRONLY, and O_RDWR.
1158
a5222a85 1159=item File::Compare
1160
1161A compare_text() function has been added, which allows custom
1162comparison functions. See L<File::Compare>.
1163
1164=item File::Find
1165
1166File::Find now works correctly when the wanted() function is either
1167autoloaded or is a symbolic reference.
1168
08cd8952 1169A bug that caused File::Find to lose track of the working directory
a5222a85 1170when pruning top-level directories has been fixed.
1171
81793b90 1172File::Find now also supports several other options to control its
1173behavior. It can follow symbolic links if the C<follow> option is
1174specified. Enabling the C<no_chdir> option will make File::Find skip
1175changing the current directory when walking directories. The C<untaint>
1176flag can be useful when running with taint checks enabled.
1177
1178See L<File::Find>.
1179
becf2bd3 1180=item File::Glob
1181
52bb0670 1182This extension implements BSD-style file globbing. By default,
1183it will also be used for the internal implementation of the glob()
1184operator. See L<File::Glob>.
becf2bd3 1185
f505c983 1186=item File::Spec
1187
1188New methods have been added to the File::Spec module: devnull() returns
19799a22 1189the name of the null device (/dev/null on Unix) and tmpdir() the name of
14218588 1190the temp directory (normally /tmp on Unix). There are now also methods
f505c983 1191to convert between absolute and relative filenames: abs2rel() and
14218588 1192rel2abs(). For compatibility with operating systems that specify volume
1193names in file paths, the splitpath(), splitdir(), and catdir() methods
f505c983 1194have been added.
1195
1196=item File::Spec::Functions
1197
1198The new File::Spec::Functions modules provides a function interface
14218588 1199to the File::Spec module. Allows shorthand
f505c983 1200
14218588 1201 $fullname = catfile($dir1, $dir2, $file);
f505c983 1202
1203instead of
1204
14218588 1205 $fullname = File::Spec->catfile($dir1, $dir2, $file);
f505c983 1206
a5222a85 1207=item Getopt::Long
1208
c6edd1b7 1209Getopt::Long licensing has changed to allow the Perl Artistic License
1210as well as the GPL. It used to be GPL only, which got in the way of
1211non-GPL applications that wanted to use Getopt::Long.
1212
1213Getopt::Long encourages the use of Pod::Usage to produce help
1214messages. For example:
1215
1216 use Getopt::Long;
1217 use Pod::Usage;
1218 my $man = 0;
1219 my $help = 0;
1220 GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
1221 pod2usage(1) if $help;
1222 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
1223
1224 __END__
1225
1226 =head1 NAME
1227
1228 sample - Using GetOpt::Long and Pod::Usage
1229
1230 =head1 SYNOPSIS
1231
1232 sample [options] [file ...]
1233
1234 Options:
1235 -help brief help message
1236 -man full documentation
1237
1238 =head1 OPTIONS
1239
1240 =over 8
1241
1242 =item B<-help>
1243
1244 Print a brief help message and exits.
1245
1246 =item B<-man>
1247
1248 Prints the manual page and exits.
1249
1250 =back
1251
1252 =head1 DESCRIPTION
1253
1254 B<This program> will read the given input file(s) and do someting
1255 useful with the contents thereof.
1256
1257 =cut
1258
1259See L<Pod::Usage> for details.
1260
1261A bug that prevented the non-option call-back E<lt>E<gt> from being
1262specified as the first argument has been fixed.
1263
1264To specify the characters E<lt> and E<gt> as option starters, use
1265E<gt>E<lt>. Note, however, that changing option starters is strongly
1266deprecated.
a5222a85 1267
1268=item IO
1269
1270write() and syswrite() will now accept a single-argument
1271form of the call, for consistency with Perl's syswrite().
1272
1273You can now create a TCP-based IO::Socket::INET without forcing
1274a connect attempt. This allows you to configure its options
1275(like making it non-blocking) and then call connect() manually.
1276
1277A bug that prevented the IO::Socket::protocol() accessor
1278from ever returning the correct value has been corrected.
1279
1280=item JPL
1281
1282Java Perl Lingo is now distributed with Perl. See jpl/README
1283for more information.
1284
883d36a6 1285=item lib
1286
1287C<use lib> now weeds out any trailing duplicate entries.
1288C<no lib> removes all named entries.
1289
e16b8f49 1290=item Math::BigInt
1291
437784d6 1292The bitwise operations C<E<lt>E<lt>>, C<E<gt>E<gt>>, C<&>, C<|>,
e16b8f49 1293and C<~> are now supported on bigints.
1294
b7d8191e 1295=item Math::Complex
7711098a 1296
14218588 1297The accessor methods Re, Im, arg, abs, rho, and theta can now also
868cb350 1298act as mutators (accessor $z->Re(), mutator $z->Re(3)).
b7d8191e 1299
1300=item Math::Trig
1301
14218588 1302A little bit of radial trigonometry (cylindrical and spherical),
1303radial coordinate conversions, and the great circle distance were added.
b7d8191e 1304
a5222a85 1305=item Pod::Parser
1306
1307[TODO - Brad Appleton <bradapp@enteract.com>]
1308
1309=item Pod::Text and Pod::Man
1310
1311[TODO - Russ Allbery <rra@stanford.edu>]
1312
f4b9d880 1313=item SDBM_File
1314
1315An EXISTS method has been added to this module (and sdbm_exists() has
1316been added to the underlying sdbm library), so one can now call exists
14218588 1317on an SDBM_File tied hash and get the correct result, rather than a
f4b9d880 1318runtime error.
1319
a5222a85 1320A bug that may have caused data loss when more than one disk block
1321happens to be read from the database in a single FETCH() has been
1322fixed.
1323
06ef4121 1324=item Time::Local
1325
1326The timelocal() and timegm() functions used to silently return bogus
437784d6 1327results when the date fell outside the machine's integer range. They
a5222a85 1328now consistently croak() if the date falls in an unsupported range.
06ef4121 1329
8fe0a5c4 1330=item Win32
1331
1332The error return value in list context has been changed for all functions
14218588 1333that return a list of values. Previously these functions returned a list
1334with a single element C<undef> if an error occurred. Now these functions
1335return the empty list in these situations. This applies to the following
8fe0a5c4 1336functions:
1337
14218588 1338 Win32::FsType
1339 Win32::GetOSVersion
8fe0a5c4 1340
1341The remaining functions are unchanged and continue to return C<undef> on
1342error even in list context.
1343
1344The Win32::SetLastError(ERROR) function has been added as a complement
1345to the Win32::GetLastError() function.
1346
1347The new Win32::GetFullPathName(FILENAME) returns the full absolute
14218588 1348pathname for FILENAME in scalar context. In list context it returns
1349a two-element list containing the fully qualified directory name and
501fbaef 1350the filename. See L<Win32>.
8fe0a5c4 1351
9fe6733a 1352=item DBM Filters
1353
1354A new feature called "DBM Filters" has been added to all the
14218588 1355DBM modules--DB_File, GDBM_File, NDBM_File, ODBM_File, and SDBM_File.
1356DBM Filters add four new methods to each DBM module:
9fe6733a 1357
1358 filter_store_key
1359 filter_store_value
1360 filter_fetch_key
1361 filter_fetch_value
1362
14218588 1363These can be used to filter key-value pairs before the pairs are
9fe6733a 1364written to the database or just after they are read from the database.
1365See L<perldbmfilter> for further information.
1366
b7d8191e 1367=back
3e8c4fa0 1368
1369=head2 Pragmata
1370
437784d6 1371C<use attrs> is now obsolete, and is only provided for
09bef843 1372backward-compatibility. It's been replaced by the C<sub : attributes>
1373syntax. See L<perlsub/"Subroutine Attributes"> and L<attributes>.
1374
14218588 1375C<use utf8> to enable UTF-8 and Unicode support.
43165c05 1376
1377C<use caller 'encoding'> allows modules to inherit pragmatic attributes
1378from the caller's context. C<encoding> is currently the only supported
1379attribute.
9d73390d 1380
4438c4b7 1381Lexical warnings pragma, C<use warnings;>, to control optional warnings.
a5222a85 1382See L<perllexwarn>.
6c67e1bb 1383
67d3893f 1384C<use filetest> to control the behaviour of filetests (C<-r> C<-w>
1385...). Currently only one subpragma implemented, "use filetest
1386'access';", that uses access(2) or equivalent to check permissions
1387instead of using stat(2) as usual. This matters in filesystems
1388where there are ACLs (access control lists): the stat(2) might lie,
1389but access(2) knows better.
6c67e1bb 1390
ba8251e8 1391=head1 Utility Changes
1392
a5222a85 1393=head2 h2ph
1394
1395[TODO - Kurt Starsinic <kstar@chapin.edu>]
1396
1397=head2 perlcc
1398
1399C<perlcc> now supports the C and Bytecode backends. By default,
1400it generates output from the simple C backend rather than the
1401optimized C backend.
1402
1403Support for non-Unix platforms has been improved.
1404
1405=head2 h2xs
1406
1407change#4232
1408[TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>]
e02fdbd2 1409
ba8251e8 1410=head1 Documentation Changes
1411
5fdc711f 1412=over 4
1413
883d36a6 1414=item perlcompile.pod
1415
1416An introduction to using the Perl Compiler suite.
1417
c7c04614 1418=item perlfilter.pod
1419
1420An introduction to writing Perl source filters.
1421
883d36a6 1422=item perlhack.pod
1423
1424Some guidelines for hacking the Perl source code.
1425
5fdc711f 1426=item perlopentut.pod
f8284313 1427
5fdc711f 1428A tutorial on using open() effectively.
1429
1430=item perlreftut.pod
1431
1432A tutorial that introduces the essentials of references.
1433
14218588 1434=item perltootc.pod
1435
1436A tutorial on managing class data for object modules.
1437
5fdc711f 1438=back
e02fdbd2 1439
73b437c8 1440=head1 New or Changed Diagnostics
ba8251e8 1441
a99ba403 1442=over 4
1443
09bef843 1444=item "my sub" not yet implemented
1445
1446(F) Lexically scoped subroutines are not yet implemented. Don't try that
1447yet.
1448
a99ba403 1449=item '!' allowed only after types %s
1450
1451(F) The '!' is allowed in pack() and unpack() only after certain types.
1452See L<perlfunc/pack>.
1453
1454=item / cannot take a count
1455
1456(F) You had an unpack template indicating a counted-length string,
1457but you have also specified an explicit size for the string.
1458See L<perlfunc/pack>.
1459
1460=item / must be followed by a, A or Z
1461
1462(F) You had an unpack template indicating a counted-length string,
1463which must be followed by one of the letters a, A or Z
1464to indicate what sort of string is to be unpacked.
1465See L<perlfunc/pack>.
1466
1467=item / must be followed by a*, A* or Z*
1468
437784d6 1469(F) You had a pack template indicating a counted-length string,
a99ba403 1470Currently the only things that can have their length counted are a*, A* or Z*.
1471See L<perlfunc/pack>.
1472
1473=item / must follow a numeric type
1474
1475(F) You had an unpack template that contained a '#',
1476but this did not follow some numeric unpack specification.
1477See L<perlfunc/pack>.
1478
a99ba403 1479=item /%s/: Unrecognized escape \\%c passed through
1480
1481(W) You used a backslash-character combination which is not recognized
1482by Perl. This combination appears in an interpolated variable or a
1028017a 1483C<'>-delimited regular expression. The character was understood literally.
1484
1485=item /%s/: Unrecognized escape \\%c in character class passed through
1486
1487(W) You used a backslash-character combination which is not recognized
1488by Perl inside character classes. The character was understood literally.
a99ba403 1489
1490=item /%s/ should probably be written as "%s"
1491
1492(W) You have used a pattern where Perl expected to find a string,
437784d6 1493as in the first argument to C<join>. Perl will treat the true
a99ba403 1494or false result of matching the pattern against $_ as the string,
1495which is probably not what you had in mind.
1496
1497=item %s() called too early to check prototype
1498
1499(W) You've called a function that has a prototype before the parser saw a
1500definition or declaration for it, and Perl could not check that the call
1501conforms to the prototype. You need to either add an early prototype
1502declaration for the subroutine in question, or move the subroutine
1503definition ahead of the call to get proper prototype checking. Alternatively,
1504if you are certain that you're calling the function correctly, you may put
1505an ampersand before the name to avoid the warning. See L<perlsub>.
1506
09bef843 1507=item %s package attribute may clash with future reserved word: %s
1508
1509(W) A lowercase attribute name was used that had a package-specific handler.
1510That name might have a meaning to Perl itself some day, even though it
1511doesn't yet. Perhaps you should use a mixed-case attribute name, instead.
1512See L<attributes>.
1513
a99ba403 1514=item (in cleanup) %s
6b121555 1515
a99ba403 1516(W) This prefix usually indicates that a DESTROY() method raised
1517the indicated exception. Since destructors are usually called by
1518the system at arbitrary points during execution, and often a vast
1519number of times, the warning is issued only once for any number
1520of failures that would otherwise result in the same message being
1521repeated.
1522
1523Failure of user callbacks dispatched using the C<G_KEEPERR> flag
1524could also result in this warning. See L<perlcall/G_KEEPERR>.
1525
1526=item <> should be quotes
1527
1528(F) You wrote C<require E<lt>fileE<gt>> when you should have written
1529C<require 'file'>.
1530
1531=item Attempt to join self
1532
1533(F) You tried to join a thread from within itself, which is an
1534impossible task. You may be joining the wrong thread, or you may
1535need to move the join() to some other thread.
1536
1537=item Bad evalled substitution pattern
1538
1539(F) You've used the /e switch to evaluate the replacement for a
1540substitution, but perl found a syntax error in the code to evaluate,
1541most likely an unexpected right brace '}'.
1542
1543=item Bad realloc() ignored
1544
1545(S) An internal routine called realloc() on something that had never been
1546malloc()ed in the first place. Mandatory, but can be disabled by
1547setting environment variable C<PERL_BADFREE> to 1.
1548
1549=item Binary number > 0b11111111111111111111111111111111 non-portable
1550
1551(W) The binary number you specified is larger than 2**32-1
1552(4294967295) and therefore non-portable between systems. See
1553L<perlport> for more on portability concerns.
1554
1555=item Bit vector size > 32 non-portable
1556
1557(W) Using bit vector sizes larger than 32 is non-portable.
1558
1559=item Buffer overflow in prime_env_iter: %s
1560
1561(W) A warning peculiar to VMS. While Perl was preparing to iterate over
1562%ENV, it encountered a logical name or symbol definition which was too long,
1563so it was truncated to the string shown.
1564
1565=item Can't check filesystem of script "%s"
1566
1567(P) For some reason you can't check the filesystem of the script for nosuid.
1568
0b5b802d 1569=item Can't ignore signal CHLD, forcing to default
1570
1571(W) Perl has detected that it is being run with the SIGCHLD signal
1572(sometimes known as SIGCLD) disabled. Since disabling this signal
1573will interfere with proper determination of exit status of child
1574processes, Perl has reset the signal to its default value.
1575This situation typically indicates that the parent program under
1576which Perl may be running (e.g. cron) is being very careless.
1577
a99ba403 1578=item Can't modify non-lvalue subroutine call
1579
437784d6 1580(F) Subroutines meant to be used in lvalue context should be declared as
1581such, see L<perlsub/"Lvalue subroutines">.
a99ba403 1582
1583=item Can't read CRTL environ
1584
1585(S) A warning peculiar to VMS. Perl tried to read an element of %ENV
1586from the CRTL's internal environment array and discovered the array was
1587missing. You need to figure out where your CRTL misplaced its environ
1588or define F<PERL_ENV_TABLES> (see L<perlvms>) so that environ is not searched.
1589
1590=item Can't remove %s: %s, skipping file
1591
1592(S) You requested an inplace edit without creating a backup file. Perl
1593was unable to remove the original file to replace it with the modified
1594file. The file was left unmodified.
1595
1596=item Can't return %s from lvalue subroutine
1597
1598(F) Perl detected an attempt to return illegal lvalues (such
1599as temporary or readonly values) from a subroutine used as an lvalue.
1600This is not allowed.
1601
1602=item Can't weaken a nonreference
1603
1604(F) You attempted to weaken something that was not a reference. Only
1605references can be weakened.
1606
1607=item Character class [:%s:] unknown
1608
1609(F) The class in the character class [: :] syntax is unknown.
437784d6 1610See L<perlre>.
a99ba403 1611
1612=item Character class syntax [%s] belongs inside character classes
1613
1614(W) The character class constructs [: :], [= =], and [. .] go
1615I<inside> character classes, the [] are part of the construct,
437784d6 1616for example: /[012[:alpha:]345]/. Note that [= =] and [. .]
1617are not currently implemented; they are simply placeholders for
1618future extensions.
a99ba403 1619
1620=item Constant is not %s reference
1621
1622(F) A constant value (perhaps declared using the C<use constant> pragma)
1623is being dereferenced, but it amounts to the wrong type of reference. The
1624message indicates the type of reference that was expected. This usually
1625indicates a syntax error in dereferencing the constant value.
1626See L<perlsub/"Constant Functions"> and L<constant>.
1627
1628=item constant(%s): %%^H is not localized
1629
1630(F) When setting compile-time-lexicalized hash %^H one should set the
1631corresponding bit of $^H as well.
1632
1633=item constant(%s): %s
1634
1635(F) Compile-time-substitutions (such as overloaded constants and
1636character names) were not correctly set up.
1637
1638=item defined(@array) is deprecated
1639
1640(D) defined() is not usually useful on arrays because it checks for an
1641undefined I<scalar> value. If you want to see if the array is empty,
1642just use C<if (@array) { # not empty }> for example.
1643
1644=item defined(%hash) is deprecated
1645
1646(D) defined() is not usually useful on hashes because it checks for an
1647undefined I<scalar> value. If you want to see if the hash is empty,
1648just use C<if (%hash) { # not empty }> for example.
1649
1650=item Did not produce a valid header
1651
1652See Server error.
1653
1654=item Document contains no data
1655
1656See Server error.
1657
1658=item entering effective %s failed
1659
1660(F) While under the C<use filetest> pragma, switching the real and
1661effective uids or gids failed.
6b121555 1662
73b437c8 1663=item false [] range "%s" in regexp
1664
1665(W) A character class range must start and end at a literal character, not
1666another character class like C<\d> or C<[:alpha:]>. The "-" in your false
1667range is interpreted as a literal "-". Consider quoting the "-", "\-".
1668See L<perlre>.
1669
af8c498a 1670=item Filehandle %s opened only for output
6b121555 1671
af8c498a 1672(W) You tried to read from a filehandle opened only for writing. If you
437784d6 1673intended it to be a read/write filehandle, you needed to open it with
af8c498a 1674"+E<lt>" or "+E<gt>" or "+E<gt>E<gt>" instead of with "E<lt>" or nothing. If
1675you intended only to read from the file, use "E<lt>". See
1676L<perlfunc/open>.
e02fdbd2 1677
a99ba403 1678=item Hexadecimal number > 0xffffffff non-portable
1679
1680(W) The hexadecimal number you specified is larger than 2**32-1
1681(4294967295) and therefore non-portable between systems. See
1682L<perlport> for more on portability concerns.
1683
1684=item Ill-formed CRTL environ value "%s"
1685
1686(W) A warning peculiar to VMS. Perl tried to read the CRTL's internal
1687environ array, and encountered an element without the C<=> delimiter
1688used to spearate keys from values. The element is ignored.
1689
1690=item Ill-formed message in prime_env_iter: |%s|
1691
1692(W) A warning peculiar to VMS. Perl tried to read a logical name
1693or CLI symbol definition when preparing to iterate over %ENV, and
1694didn't see the expected delimiter between key and value, so the
1695line was ignored.
1696
1697=item Illegal binary digit %s
1698
437784d6 1699(F) You used a digit other than 0 or 1 in a binary number.
a99ba403 1700
1701=item Illegal binary digit %s ignored
1702
1703(W) You may have tried to use a digit other than 0 or 1 in a binary number.
1704Interpretation of the binary number stopped before the offending digit.
1705
1706=item Illegal number of bits in vec
1707
1708(F) The number of bits in vec() (the third argument) must be a power of
1709two from 1 to 32 (or 64, if your platform supports that).
1710
1711=item Integer overflow in %s number
1712
1713(W) The hexadecimal, octal or binary number you have specified either
c6edd1b7 1714as a literal or as an argument to hex() or oct() is too big for your
a99ba403 1715architecture, and has been converted to a floating point number. On a
171632-bit architecture the largest hexadecimal, octal or binary number
1717representable without overflow is 0xFFFFFFFF, 037777777777, or
17180b11111111111111111111111111111111 respectively. Note that Perl
1719transparently promotes all numbers to a floating point representation
1720internally--subject to loss of precision errors in subsequent
1721operations.
1722
09bef843 1723=item Invalid %s attribute: %s
1724
1725The indicated attribute for a subroutine or variable was not recognized
1726by Perl or by a user-supplied handler. See L<attributes>.
1727
1728=item Invalid %s attributes: %s
1729
1730The indicated attributes for a subroutine or variable were not recognized
1731by Perl or by a user-supplied handler. See L<attributes>.
1732
73b437c8 1733=item invalid [] range "%s" in regexp
1734
1735The offending range is now explicitly displayed.
1736
09bef843 1737=item Invalid separator character %s in attribute list
1738
1739(F) Something other than a comma or whitespace was seen between the
1740elements of an attribute list. If the previous attribute
1741had a parenthesised parameter list, perhaps that list was terminated
1742too soon. See L<attributes>.
1743
a99ba403 1744=item Invalid separator character %s in subroutine attribute list
1745
1746(F) Something other than a comma or whitespace was seen between the
1747elements of a subroutine attribute list. If the previous attribute
1748had a parenthesised parameter list, perhaps that list was terminated
1749too soon.
1750
1751=item leaving effective %s failed
1752
1753(F) While under the C<use filetest> pragma, switching the real and
1754effective uids or gids failed.
1755
1756=item Lvalue subs returning %s not implemented yet
1757
1758(F) Due to limitations in the current implementation, array and hash
1759values cannot be returned in subroutines used in lvalue context.
1760See L<perlsub/"Lvalue subroutines">.
1761
1762=item Method %s not permitted
1763
1764See Server error.
1765
1766=item Missing %sbrace%s on \N{}
1767
1768(F) Wrong syntax of character name literal C<\N{charname}> within
1769double-quotish context.
1770
06eaf0bc 1771=item Missing command in piped open
1772
1773(W) You used the C<open(FH, "| command")> or C<open(FH, "command |")>
1774construction, but the command was missing or blank.
1775
09bef843 1776=item Missing name in "my sub"
1777
1778(F) The reserved syntax for lexically scoped subroutines requires that they
1779have a name with which they can be found.
1780
a99ba403 1781=item no UTC offset information; assuming local time is UTC
1782
1783(S) A warning peculiar to VMS. Perl was unable to find the local
1784timezone offset, so it's assuming that local system time is equivalent
1785to UTC. If it's not, define the logical name F<SYS$TIMEZONE_DIFFERENTIAL>
1786to translate to the number of seconds which need to be added to UTC to
1787get local time.
1788
1789=item Octal number > 037777777777 non-portable
1790
1791(W) The octal number you specified is larger than 2**32-1 (4294967295)
1792and therefore non-portable between systems. See L<perlport> for more
1793on portability concerns.
1794
1795See also L<perlport> for writing portable code.
1796
1797=item panic: del_backref
1798
1799(P) Failed an internal consistency check while trying to reset a weak
1800reference.
1801
1802=item panic: kid popen errno read
1803
1804(F) forked child returned an incomprehensible message about its errno.
1805
1806=item panic: magic_killbackrefs
1807
1808(P) Failed an internal consistency check while trying to reset all weak
1809references to an object.
1810
1811=item Possible Y2K bug: %s
1812
1813(W) You are concatenating the number 19 with another number, which
1814could be a potential Year 2000 problem.
1815
1816=item Premature end of script headers
1817
1818See Server error.
1819
0b5b802d 1820=item Repeat count in pack overflows
1821
1822(F) You can't specify a repeat count so large that it overflows
1823your signed integers. See L<perlfunc/pack>.
1824
1825=item Repeat count in unpack overflows
1826
1827(F) You can't specify a repeat count so large that it overflows
1828your signed integers. See L<perlfunc/unpack>.
1829
a99ba403 1830=item realloc() of freed memory ignored
1831
1832(S) An internal routine called realloc() on something that had already
1833been freed.
1834
1835=item Reference is already weak
1836
1837(W) You have attempted to weaken a reference that is already weak.
1838Doing so has no effect.
1839
1840=item setpgrp can't take arguments
1841
1842(F) Your system has the setpgrp() from BSD 4.2, which takes no arguments,
1843unlike POSIX setpgid(), which takes a process ID and process group ID.
1844
1845=item Strange *+?{} on zero-length expression
1846
1847(W) You applied a regular expression quantifier in a place where it
1848makes no sense, such as on a zero-width assertion.
1849Try putting the quantifier inside the assertion instead. For example,
1850the way to match "abc" provided that it is followed by three
1851repetitions of "xyz" is C</abc(?=(?:xyz){3})/>, not C</abc(?=xyz){3}/>.
1852
1853=item switching effective %s is not implemented
1854
1855(F) While under the C<use filetest> pragma, we cannot switch the
1856real and effective uids or gids.
1857
437784d6 1858=item This Perl can't reset CRTL environ elements (%s)
a99ba403 1859
1860=item This Perl can't set CRTL environ elements (%s=%s)
1861
1862(W) Warnings peculiar to VMS. You tried to change or delete an element
1863of the CRTL's internal environ array, but your copy of Perl wasn't
1864built with a CRTL that contained the setenv() function. You'll need to
1865rebuild Perl with a CRTL that does, or redefine F<PERL_ENV_TABLES> (see
1866L<perlvms>) so that the environ array isn't the target of the change to
1867%ENV which produced the warning.
1868
1869=item Unknown open() mode '%s'
1870
437784d6 1871(F) The second argument of 3-argument open() is not among the list
1872of valid modes: C<L<lt>>, C<L<gt>>, C<E<gt>E<gt>>, C<+L<lt>>,
1873C<+L<gt>>, C<+E<gt>E<gt>>, C<-|>, C<|->.
a99ba403 1874
1875=item Unknown process %x sent message to prime_env_iter: %s
1876
1877(P) An error peculiar to VMS. Perl was reading values for %ENV before
1878iterating over it, and someone else stuck a message in the stream of
1879data Perl expected. Someone's very confused, or perhaps trying to
1880subvert Perl's population of %ENV for nefarious purposes.
1881
af8c498a 1882=item Unrecognized escape \\%c passed through
1883
1884(W) You used a backslash-character combination which is not recognized
1028017a 1885by Perl. The character was understood literally.
af8c498a 1886
09bef843 1887=item Unterminated attribute parameter in attribute list
1888
1889(F) The lexer saw an opening (left) parenthesis character while parsing an
1890attribute list, but the matching closing (right) parenthesis
1891character was not found. You may need to add (or remove) a backslash
1892character to get your parentheses to balance. See L<attributes>.
1893
1894=item Unterminated attribute list
1895
1896(F) The lexer found something other than a simple identifier at the start
1897of an attribute, and it wasn't a semicolon or the start of a
1898block. Perhaps you terminated the parameter list of the previous attribute
1899too soon. See L<attributes>.
1900
09bef843 1901=item Unterminated attribute parameter in subroutine attribute list
1902
1903(F) The lexer saw an opening (left) parenthesis character while parsing a
1904subroutine attribute list, but the matching closing (right) parenthesis
1905character was not found. You may need to add (or remove) a backslash
1906character to get your parentheses to balance.
1907
1908=item Unterminated subroutine attribute list
1909
1910(F) The lexer found something other than a simple identifier at the start
1911of a subroutine attribute, and it wasn't a semicolon or the start of a
1912block. Perhaps you terminated the parameter list of the previous attribute
1913too soon.
1914
a99ba403 1915=item Value of CLI symbol "%s" too long
eb6e2d6f 1916
a99ba403 1917(W) A warning peculiar to VMS. Perl tried to read the value of an %ENV
1918element from a CLI symbol table, and found a resultant string longer
1919than 1024 characters. The return value has been truncated to 1024
1920characters.
eb6e2d6f 1921
a99ba403 1922=item Version number must be a constant number
ba8251e8 1923
a99ba403 1924(P) The attempt to translate a C<use Module n.n LIST> statement into
1925its equivalent C<BEGIN> block found an internal inconsistency with
1926the version number.
1927
1928=back
27806c82 1929
a5222a85 1930=head1 Obsolete Diagnostics
3175b8cd 1931
a99ba403 1932=over 4
1933
1934=item Character class syntax [: :] is reserved for future extensions
1935
1936(W) Within regular expression character classes ([]) the syntax beginning
1937with "[:" and ending with ":]" is reserved for future extensions.
1938If you need to represent those character sequences inside a regular
1939expression character class, just quote the square brackets with the
1940backslash: "\[:" and ":\]".
1941
1942=item Ill-formed logical name |%s| in prime_env_iter
1943
1944(W) A warning peculiar to VMS. A logical name was encountered when preparing
1945to iterate over %ENV which violates the syntactic rules governing logical
1946names. Because it cannot be translated normally, it is skipped, and will not
1947appear in %ENV. This may be a benign occurrence, as some software packages
1948might directly modify logical name tables and introduce nonstandard names,
1949or it may indicate that a logical name table has been corrupted.
1950
1951=item regexp too big
1952
1953(F) The current implementation of regular expressions uses shorts as
1954address offsets within a string. Unfortunately this means that if
1955the regular expression compiles to longer than 32767, it'll blow up.
1956Usually when you want a regular expression this big, there is a better
1957way to do it with multiple statements. See L<perlre>.
1958
1959=item Use of "$$<digit>" to mean "${$}<digit>" is deprecated
1960
1961(D) Perl versions before 5.004 misinterpreted any type marker followed
1962by "$" and a digit. For example, "$$0" was incorrectly taken to mean
1963"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004.
1964
1965However, the developers of Perl 5.004 could not fix this bug completely,
1966because at least two widely-used modules depend on the old meaning of
1967"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the
1968old (broken) way inside strings; but it generates this message as a
1969warning. And in Perl 5.005, this special treatment will cease.
1970
1971=back
3175b8cd 1972
ba8251e8 1973=head1 BUGS
1974
437784d6 1975If you find what you think is a bug, you might check the
14218588 1976articles recently posted to the comp.lang.perl.misc newsgroup.
ba8251e8 1977There may also be information at http://www.perl.com/perl/, the Perl
1978Home Page.
1979
1980If you believe you have an unreported bug, please run the B<perlbug>
14218588 1981program included with your release. Make sure to trim your bug down
ba8251e8 1982to a tiny but sufficient test case. Your bug report, along with the
14218588 1983output of C<perl -V>, will be sent off to perlbug@perl.com to be
ba8251e8 1984analysed by the Perl porting team.
1985
1986=head1 SEE ALSO
1987
1988The F<Changes> file for exhaustive details on what changed.
1989
1990The F<INSTALL> file for how to build Perl.
1991
1992The F<README> file for general stuff.
1993
1994The F<Artistic> and F<Copying> files for copyright information.
1995
1996=head1 HISTORY
1997
a5222a85 1998Written by Gurusamy Sarathy <F<gsar@activestate.com>>, with many
1999contributions from The Perl Porters.
ba8251e8 2000
2001Send omissions or corrections to <F<perlbug@perl.com>>.
2002
2003=cut