ガンガンperlをやろう

# ループ処理
my $i = 0;
while($i < 10){
	print "i = $i\n";
	$i++;
}
&#91;/perl&#93;

vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9

for文
&#91;perl&#93;
for(my $i = 0; $i < 10; $i++){
	print "i = $i\n";
}
&#91;/perl&#93;

おおおおおお、foreachが可笑しなことになってる。。
&#91;perl&#93;
my @colors = qw(red green blue orange pink);

foreach my $color (@colors){
	print "color = $color\n";
}
&#91;/perl&#93;

vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
color = red
color = green
color = blue
color = orange
color = pink

ナニコレ?
&#91;perl&#93;
my @colors = qw(red green blue orange pink);

foreach (@colors){
	print "color = $_\n";
}
&#91;/perl&#93;

vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
color = red
color = green
color = blue
color = orange
color = pink

これは。。。
&#91;perl&#93;
my %sales = ("tanaka"=>150, "suzuki"=>300, "ohira"=>200);

foreach my $key (keys(%sales)){
		print "sales for $key in $sales{$key}\n"
}

vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
sales for tanaka in 150
sales for suzuki in 300
sales for ohira in 200