Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl Puzzles What is the output of each of these code snippets?

Similar presentations


Presentation on theme: "Perl Puzzles What is the output of each of these code snippets?"— Presentation transcript:

1 Perl Puzzles What is the output of each of these code snippets?
Think them through first, then test them out!

2 Print print (2+3)*4; # Why do you get the unexpected answer?
Compare these two statements print 5 < 3; print 5 > 3; print 5 + 3; print “5 + 3”;

3 Arrays @A = (98..102); print 0 + reverse @A; @B = qw(a b c);
@B = qw(a b c); unshift

4 $i = 27; $j = “$i + 1”; print $j; print ((‘Hello\t’
$i = 27; $j = “$i + 1”; print $j; print ((‘Hello\t’ . “world\n” x 2\n”); print ((0xff % 0b11) + 012);

5 printf $x = -17.12345678; @A = qw/7 -2.3 6.99 2e5/;
printf "\$x =0%-3o", -$x; printf "\$x =0%-3x", -$x; printf "\$x =%4.2e", $x; printf "\$A[%d] = %g", $#A, $A[-1];


Download ppt "Perl Puzzles What is the output of each of these code snippets?"

Similar presentations


Ads by Google