more fun with operators

This commit is contained in:
Dan Buch 2011-01-04 21:32:44 -05:00
parent 7e2e008a55
commit 63889cdac3

View File

@ -51,13 +51,48 @@ print '$a = ';
my $a = <STDIN>; my $a = <STDIN>;
print '$b = '; print '$b = ';
my $b = <STDIN>; my $b = <STDIN>;
print '$c = ';
my $c = <STDIN>;
my $ncookies = 0;
sub printcookies {
print "I like cookies " . $ncookies++ . "\n";
}
if ($a == 5 && $b == 2) { if ($a == 5 && $b == 2) {
print "I like cookies\n"; printcookies();
} }
if ($a == 5 && $b == 2 || $c == 2) { if ($a == 5 && $b == 2 || $c == 2) {
print "I like cookies\n"; printcookies();
}
if ($a == 5 and ($b == 2 || $c == 3)) {
printcookies();
}
if ($a == 5 && $b == 2 or $c == 3) {
printcookies();
}
if ($a == 5 && $b == 2 or $c == 3) {
printcookies();
}
if (($a == 5 && $b == 2) or $c == 3) {
printcookies();
}
($a, $b) = (5, 2);
if ($a == 4 && $b < 3) {
printcookies();
} }