I'm trying to find the difference in seconds between two dates. The two (and only two) dates come as standard out like:
Sun 09 30 06 42 36 2007 Tue 10 02 06 01 55 2007
(Note: the months correspond to September and October respectively.)

I tried to do this with awk because I use awk in plenty of other places but awk's mktime() is a GNU-only addition it seems and I only have access to barebones Solaris installs. The only alternative remaining I think is Perl's timelocal function in Time::Local which I believe is a part of the standard install, right? My goal is to put a Perl one-liner in a sh script and this is the last piece in the pipe. I've already written a Perl script which works but purely as an exercise for the monkish community, where are the improvements I'm missing?

Here's what I have currently but I am actively working on it though:
my @array; while (<>) { chomp; my @fields = split; shift @fields; unshift(@fields, pop(@fields)); $fields[1]--; # decrement the month, timelocal is zero-based push (@array, timelocal (reverse @fields)); } print $array[1] - $array[0];
"The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why." -- `man perl`

In reply to Diff'ing dates (solved) by LighthouseJ

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.