Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to re-order badly formed dates within a delimited string?

by monsterzero (Monk)
on Jun 15, 2006 at 18:54 UTC ( #555584=note: print w/ replies, xml ) Need Help??


in reply to How to re-order badly formed dates within a delimited string?

Hello, In order to sort by date you will need to convert that format to one that can be sorted. This is where you may want to use the DateTime suite of modules. Hope this helps

use strict; use warnings; use Datetime; use DateTime::Format::Strptime; my $Strp = new DateTime::Format::Strptime( pattern => '%a %d-%b-%y', ) +; my @dates; while (<DATA>) { chomp; my @date_text = split(/\|/); push( @dates, $Strp->parse_datetime( $date_text[-1] ) ); } my @sorted_dates = sort @dates; print map { "$_\n" } @sorted_dates; __DATA__ |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sat 09-DEC-06| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sat 09-JUN-07| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sat 10-FEB-07| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sat 14-APR-07| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sat 28-OCT-06| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sun 10-DEC-06| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sun 10-JUN-07| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sun 15-APR-07| |Puerto Rico||Santiago Apostol Catholic School|Las Croabas Road, Urb S +anta Isidra|Fajardo|PR||00738|Modesto|Garcia|Counselor|787/863-0524|7 +87/863-6655|Sun 29-OCT-06|


Comment on Re: How to re-order badly formed dates within a delimited string?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-07-23 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (131 votes), past polls