Evaluation of if statements

#!/usr/bin/perl
my ($x,$a)=(0,1);

if ($a || $x++) {
print “foon”;
}
print “$x”;

At last, it will print 0 because, during the evaluation of if statement, since $a = 1, the next part of ‘or’ wont be evaluated. So $x will still remain 0.

Leave a Reply

Your email address will not be published. Required fields are marked *