Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: String manipulation

by Athanasius (Abbot)
on Dec 15, 2012 at 03:01 UTC ( #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,


Comment on Re: String manipulation
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2015-07-31 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls