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));
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.