This subroutine will convert numbers (1) into placings (1st) then return it.
sub nth { my $num = $_[0]; if ($num > 10 && $num < 20) { my $r = $num . "th"; return $r; } else { my $end = substr($num, -1); if($end == 1) { return $num . "st"; } elsif($end == 2) { return $num . "nd"; } elsif($end == 3) { return $num . "rd"; } else { return $num . "th"; } } }

Replies are listed 'Best First'.
RE: Nth
by merlyn (Sage) on May 02, 2000 at 02:22 UTC