From: Perl 5 Porters Date: Sun, 8 Sep 1996 22:09:04 +0000 (+0000) Subject: More (and less!) 425traps X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e378fdf771d0a60d95ee1eed3e78057436dc10c;p=p5sagit%2Fp5-mst-13.2.git More (and less!) 425traps Here's documentation on the change in split's behavior between Perl 4 and Perl 5. Large integer traps Precedence warn STDERR Change blank lines to empty lines. --- diff --git a/pod/perltrap.pod b/pod/perltrap.pod index c3a3165..984ba3b 100644 --- a/pod/perltrap.pod +++ b/pod/perltrap.pod @@ -480,7 +480,7 @@ Double darn. # perl4 prints: a is foo bar, b is baz # perl5 errors: Bare word found where operator expected - + =item * Discontinuance The archaic while/if BLOCK BLOCK syntax is no longer supported. @@ -537,6 +537,18 @@ Otherwise changing $var will clobber the values of @list. (This most often happens when you use C<$_> for the loop variable, and call subroutines in the loop that don't properly localize C<$_>.) +=item * Discontinuance + +C with no arguments now behaves like C (which doesn't +return an initial null field if $_ starts with whitespace), it used to +behave like C (which does). + + $_ = ' hi mom'; + print join(':', split); + + # perl4 prints: :hi:mom + # perl5 prints: hi:mom + =item * Deprecation Some error messages will be different. @@ -610,21 +622,11 @@ Formatted output and significant digits =item * Numerical -Large integer trap with autoincrement +This specific item has been deleted. It demonstrated how the autoincrement +operator would not catch when a number went over the signed int limit. Fixed +in 5.003_04. But always be wary when using large ints. If in doubt: - $a = $b = 2147483647; - print "$a $b\n"; - $a += 1; - $b++; - print "$a $b\n"; - - # perl4 prints: - 2147483647 2147483647 - 2147483648 2147483648 - - # perl5 prints: - 2147483647 2147483647 - 2147483648 -2147483648 + use Math::BigInt; =item * Numerical @@ -709,7 +711,7 @@ variable is localized subsequent to the assignment # perl4 prints: 1 2 4 # perl5 prints: Literal @fred now requires backslash - + =item * (Scalar String) Changes in unary negation (of strings) @@ -827,7 +829,7 @@ being required. # perl4 errors: There is no caller # perl5 prints: Got a 0 - + =item * (scalar context) The comma operator in a scalar context is now guaranteed to give a @@ -870,7 +872,18 @@ Perl4-to-Perl5 traps involving precedence order. =over 5 -=item * +=item * Precedence + +LHS vs. RHS when both sides are getting an op. + + @arr = ( 'left', 'right' ); + $a{shift @arr} = shift @arr; + print join( ' ', keys %a ); + + # perl4 prints: left + # perl5 prints: right + +=item * Precedence These are now semantic errors because of precedence: @@ -927,7 +940,7 @@ treats C<$::> as main C # perl 4 prints: -:a # perl 5 prints: x - + =item * Precedence concatenation precedence over filetest operator? @@ -1098,6 +1111,13 @@ reverse is no longer allowed as the name of a sort subroutine. # perl4 prints: yup yup yup yup abc # perl5 prints: abc +=item * warn() specifically implies STDERR + + warn STDERR "Foo!"; + + # perl4 prints: Foo! + # perl5 prints: String found where operator expected + =back =head2 OS Traps