working through operator examples

This commit is contained in:
Dan Buch 2011-01-04 21:26:55 -05:00
parent 748671e3fc
commit 7e2e008a55

63
cli/operators.pl Normal file
View File

@ -0,0 +1,63 @@
sub println {
printf("%s\n", shift());
}
println(4 % 3);
println(4 % 2);
println(-4 % 3);
println(4 ** 2);
println(2 ** (1/2));
my $foo = 1;
println($foo--);
println($foo);
println("dog");
$foo = 1;
println(--$foo);
println($foo);
$foo = 'd';
println(--$foo);
println($foo);
$foo = 'Z';
println($foo++);
println($foo);
$foo = 'Hello';
$foo .= ', world';
println($foo);
my $bar = '+';
$bar x= 6;
println($bar);
print '$a = ';
my $a = <STDIN>;
print '$b = ';
my $b = <STDIN>;
if ($a == 5 && $b == 2) {
print "I like cookies\n";
}
if ($a == 5 && $b == 2 || $c == 2) {
print "I like cookies\n";
}