my @sales = (300, 150, 200); # @sales $#sale: 末尾の添字 print @sales[0..$#sales];
key and value
my %sales = ("tanaka"=>300, "suzuki"=>150, "ohira"=>200); print $sales{"tanaka"};
条件分岐
my $score = 85; if ($score >= 80) { print("ok!"); }
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
ok!
my $score = 85; my $name = "Luke"; if ($name eq "Luke") { print("I am your father!"); }
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
I am your father!
ああああああ、何やってんだろう。
my $score = 85; my $name = "Luke"; if (($name eq "Luke") &&($score >= 80)) { print("I am your father!"); }