Created
December 19, 2015 04:35
-
-
Save tomcha/d7473dbd63862485cc5f to your computer and use it in GitHub Desktop.
ouyou4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my @foods; | |
print "好きな食べ物を入力して下さい。入力を終える時は END と入力して下さい。\n"; | |
for (;;){ | |
print "好きな食べ物を入力して下さい>>"; | |
my $str = <STDIN>; | |
chomp $str; | |
if ($str eq 'END'){ | |
last; | |
}else{ | |
push @foods, $str; | |
} | |
} | |
#my @rev_foods = reverse @foods; | |
my @rev_foods; | |
for (my $i = @foods - 1; $i >= 0 ;$i-- ){ | |
push @rev_foods, $foods[$i]; | |
} | |
print "\n入力された食べ物を逆順に出力します。\n\n"; | |
for my $food (@rev_foods){ | |
print "$food\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment