>>514 Perl5

%o = qw{1 st 2 nd 3 rd};
$o = $o{$_}//'th', print "$_$o\n" for 1..10,12,23;

実行
~ $ perl 15_514.pl
1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
12th
23th