Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: sorting a file by a date:"YYYY-MM-DD" field with cmp

by ikegami (Patriarch)
on Jun 16, 2015 at 17:45 UTC ( #1130653=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
       my ($aDate) = $a =~ /\bdate:\s*"(\d{4}-\d{2}-\d{2})"/;
       my ($bDate) = $b =~ /\bdate:\s*"(\d{4}-\d{2}-\d{2})"/;
    
  2. or download this
    use JSON::XS qw( decode_json );
    
    ...
          sort
             map { decode_json($_)->{date} . $_ }
                @events;
    
  3. or download this
    @events = grep /\S/, @events;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-05-17 05:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (65 votes). Check out past polls.

    Notices?