use warnings; use strict; use Template; use Lingua::EN::Numbers::Ordinate "ordinate"; my %config = ( FILTERS => { ordinal => sub { ordinate($_[0]) }, ordinal_html => sub { my $ord = ordinate($_[0]); $ord =~ s,(\D\D)\z,$1,; return $ord; } } ); my $tt2 = Template->new(\%config); $tt2->process(\*DATA, { numbers => [ 0 .. 121 ] }) or die $tt2->error; __DATA__ [% FOR i IN numbers %] Plain: [% i | ordinal %] -- HTML: [% i | ordinal_html %] [%-END %]