Use Date::Calc, here is an example:
#! /usr/bin/perl -w use CGI qw/:standard/; # first install module Date::Calc use Date::Calc qw(Date_to_Days Add_Delta_Days check_date); #@array=readpipe 'ls 'directory'/'subdirectory'.*html' ; @array=readpipe 'ls ./tmp/*html' ; # we will be sorting later #sort @array; @headings=('Title','Issue Date'); @rows=th(\@headings); foreach $n (@array) { open (HTMLFILE,$n); $issue_date=""; while (<HTMLFILE>) { if (m/<TITLE>(.+)<\/TITLE>/i){$title=$1}; # had to change / in the middle? if (m/<o:Description>(.+)<o:Description>/i) {$issue_date=$1}; } close HTMLFILE; #push(@rows, td([$title,$issue_date]) push(@temp_rows,[$title, $issue_date, # in case your date looks like "DD.MM.YYYY" Date_to_Days((split(/\./, $issue_date, 3))[2,1,0]) ]); } for my $i (sort {$a->[2] <=> $b->[2] } @temp_rows) { push(@rows, td([@{$i}[0,1]])); } print table({width=>"100%",border=>"1",bordercolor=>"#d9dae6",cellspacing=>" +1",cellpadding=>"1"},Tr({bgcolor=>"#97a5f0"},\@rows));

In reply to Re: Sorting according to date by hipe
in thread Sorting according to date by campbell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.