Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: String manipulation

by CountZero (Bishop)
on Dec 15, 2012 at 13:02 UTC ( #1008980=note: print w/replies, xml ) Need Help??


in reply to String manipulation

Assuming this is homework and you really want to surprise your teacher:
use Modern::Perl; use Date::Parse; use DateTime; while (<DATA>) { my $dt = DateTime->from_epoch( epoch => str2time($_, '+0000')); say join ' ', $dt->month_name(), $dt->day(), $dt->year(); } __DATA__ December 14th 2012 December 21st 2012 December 22nd 2012
Output:
December 14 2012 December 21 2012 December 22 2012

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: String manipulation
by BillKSmith (Prior) on Dec 15, 2012 at 15:41 UTC
    Treating the data as a date rather than a generic string can have a huge advantage in avoiding unwanted changes.
    Bill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2021-04-13 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?