http://www.perlmonks.org?node_id=1008926


in reply to String manipulation

Here is one way:

#! perl use Modern::Perl; my $a = "December 14th 2012"; my $b = "December 21st 2012"; my $c = "December 22nd 2012"; for ($a, $b, $c) { my @fields = split; $fields[1] =~ s/st|nd|rd|th//; $_ = join(' ', @fields); say; }

Output:

12:58 >perl 433_SoPW.pl December 14 2012 December 21 2012 December 22 2012 12:58 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,