Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Sort an array which contains date formatted elements

by moritz (Cardinal)
on Jul 17, 2007 at 12:35 UTC ( #627014=note: print w/ replies, xml ) Need Help??


in reply to Sort an array which contains date formatted elements

You should transform the filenames to something that can easily be compared:

my %month = ( jan => 1, feb => 2, ... ); m/webadmin_([^_]+)_(\d+)_(\d{4})\.log/; my ($month, $day, $year) = ($1, $2, $3); my $new_filename = sprintf "%04d-%02d-%02d", $year, $month{$month}, $d +ay;

You can combine that with a Schwartzian Transform.


Comment on Re: Sort an array which contains date formatted elements
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2015-07-04 19:55 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 (60 votes), past polls