Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created December 4, 2015 01:32
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/558feae8527d9788cf77 to your computer and use it in GitHub Desktop.
Save tomcha/558feae8527d9788cf77 to your computer and use it in GitHub Desktop.
48
#!/usr/bin/env perl
use strict;
use warnings;
my @num;
@num = (1..1000);
my @rev_num = reverse @num;
# エラーの時の挙動を調べる為に、
# my @sort_num = sort @rev_num;
# も試してみましょう。
my @sort_num = sort{$a <=> $b}@rev_num;
for my $i (0..999){
if ($num[$i] == $sort_num[$i]){
print "$i => ok\n";
}else{
print "$i番目の要素の\@numの値は$num[$i]、\@sort_numの値は$sort_num[$i]です。\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment