Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: String manipulation

by Athanasius (Archbishop)
on Dec 15, 2012 at 03:01 UTC ( [id://1008926]=note: print w/replies, xml ) Need Help??


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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1008926]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found