use Number::Spell; my %ord = ( one => 'first', two => 'second', three => 'third', four => 'fourth', five => 'fifth', six => 'sixth', en => 'enth', eight => 'eighth', nine => 'ninth', twelve => 'twelfth', ty => 'tieth', hundred => 'hundredth', thousand => 'thousandth', ion => 'ionth' ); my @list = qw(1st 11th 3rd 13th 83rd 11 33 1 15 1000000th); my @stringlist; foreach my $number (@list) { my $stringversion; if ($number =~ m/(\d+)(?:st|th|rd)$/i) { $stringversion = spell_number($1); $stringversion =~ s/($_)$/$ord{$_}/i for keys %ord; } else { $stringversion = spell_number($number); } push @stringlist,$stringversion; } print join(', ',@stringlist);