X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperltrap.pod;h=02abc3b03b3852526578fb132c30c56fb6e2ee66;hb=ce3f0a3cd6f30cb49f01b7811c2891acb7bab15a;hp=786dcda6074abc0253494e2f11864f9e233a7d98;hpb=daff0e373f3630eaa9dbded0adcc04185f454487;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perltrap.pod b/pod/perltrap.pod index 786dcda..02abc3b 100644 --- a/pod/perltrap.pod +++ b/pod/perltrap.pod @@ -35,7 +35,7 @@ Curly brackets are required on Cs and Cs. =item * -Variables begin with "$" or "@" in Perl. +Variables begin with "$", "@" or "%" in Perl. =item * @@ -168,7 +168,7 @@ There's no switch statement. (But it's easy to build one on the fly.) =item * -Variables begin with "$" or "@" in Perl. +Variables begin with "$", "@" or "%" in Perl. =item * @@ -438,6 +438,12 @@ whether this should be classed as a bug or not. # perl4 prints: x=10 # perl5 prints: Can't find string terminator "'" anywhere before EOF +You can avoid this problem, and remain compatible with perl4, if you +always explicitly include the package name: + + $x = 10 ; + print "x=${main'x}\n" ; + Also see precedence traps, for parsing C<$:>. =item * BugFix @@ -923,7 +929,9 @@ Perl4-to-Perl5 traps involving precedence order. =item * Precedence -LHS vs. RHS when both sides are getting an op. +LHS vs. RHS of any assignment operator. LHS is evaluated first +in perl4, second in perl5; this can affect the relationship +between side-effects in sub-expressions. @arr = ( 'left', 'right' ); $a{shift @arr} = shift @arr; @@ -999,18 +1007,6 @@ concatenation precedence over filetest operator? # perl4 prints: no output # perl5 prints: Can't modify -e in concatenation -=item * Precedence - -Assignment to value takes precedence over assignment to key in -perl5 when using the shift operator on both sides. - - @arr = ( 'left', 'right' ); - $a{shift @arr} = shift @arr; - print join( ' ', keys %a ); - - # perl4 prints: left - # perl5 prints: right - =back =head2 General Regular Expression Traps using s///, etc. @@ -1455,9 +1451,7 @@ Everything else. =over 5 -=item * Unclassified - -C/C trap using returned value +=item * C/C trap using returned value If the file doit.pl has: @@ -1478,6 +1472,14 @@ Running doit.pl gives the following: Same behavior if you replace C with C. +=item * C on empty string with LIMIT specified + + $string = ''; + @list = split(/foo/, $string, 2) + +Perl4 returns a one element list containing the empty string but Perl5 +returns an empty list. + =back As always, if any of these are ever officially declared as bugs,