Here is a Time::Local example

#!/usr/bin/perl -w use strict; use Time::Local; my %months = ( Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun => 5, Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov => 10, Dec => 12); sub get_epoch_seconds { my $line = shift; # grab a scalar localtime looking like string from the line my ($wday,$mon,$mday,$hours,$min,$sec,$year) = $line =~ m/(\w\w\w)\s+(\w\w\w)\s+(\d{1,2})\s+(\d\d):(\d\d):(\d +\d)\s+(\d{4})/; die "Unable to find time like string in line:\n$line" unless $year +; $mon = $months{$mon}; # convert to numerical months 0 - 11 return timelocal($sec,$min,$hours,$mday,$mon,$year); } my $start = time(); my $string_start = scalar localtime ( $start ); print "Current time is $start epoch seconds\n"; print "As a string this is $string_start\n"; print "Converting string back into epoch seconds: ", get_epoch_seconds +($string_start), "\n"; sleep 1; my $string_finish = localtime; print "As a string it is now $string_finish\n"; my $finish = get_epoch_seconds($string_finish); print "This is $finish epoch seconds\n"; print "Comparing our times:\n"; print "$string_finish is after $string_start\n" if $finish > $start;

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Date Comparison..? by tachyon
in thread Date Comparison..? by Anonymous Monk

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.