Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created December 19, 2015 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomcha/d7473dbd63862485cc5f to your computer and use it in GitHub Desktop.
Save tomcha/d7473dbd63862485cc5f to your computer and use it in GitHub Desktop.
ouyou4
#!/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