Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 romping around the Monastery: (4)
As of 2014-07-13 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls