package numeral; sub card2ord { my $num = shift @_; if ($num =~ m/^[\d,]+$/) { $num =~ s/(1[123])$/$1th/ or $num =~ s/([0123])$/(qw|0th 1st 2nd 3rd|)[$1]/e or $num .= 'th'; } else { my %ord = qw /one first One First ONE FIRST two second Two Second TWO SECOND three third Three Third THREE THIRD five fifth Five Fifth FIVE FIFTH eight eighth Eight Eighth EIGHT EIGHTH nine ninth Nine Ninth NINE NINETH twelve twelfth Twelve Twelfth TWELVE TWELFTH y ieth Y IETH/; $num =~ s/(one|two|three|five|eight|nine|twelve|y)$/$ord{$1}/ie or $num =~ s/([A-Z])$/${1}TH/ or $num .= 'th'; } return $num; } 1;