What is the format of your datetime value? Take a look at the cpan module Date::Parse. It will enable you to translate the string time into epoch, which is much easier to use to test for ranges.

Observe the following script:
use Date::Parse qw(str2time); my $TIME_DELTA = 5 * 60; # In Seconds # my $mintime = time - $TIME_DELTA; my $mintime = 1184200080 - $TIME_DELTA; # Harded time of '11/Jul/2007: +17:28:00' while (<DATA>) { next if ! m{(\d+/\w+/\d+:\d+:\d+:\d+)}; my $errtime = str2time($1); next if $errtime < $mintime; print "$_"; } __DATA__ 192.168.130.2 - - [11/Jul/2007:17:19:05 -0700] 192.168.174.0 - - [11/Jul/2007:17:19:57 -0700] 192.168.200.4 - - [11/Jul/2007:17:20:07 -0700] 192.168.179.60 - - [11/Jul/2007:17:20:10 -0700] 192.168.174.0 - - [11/Jul/2007:17:20:21 -0700] 192.168.204.206 - - [11/Jul/2007:17:21:20 -0700] 192.168.65.202 - - [11/Jul/2007:17:21:20 -0700] 192.168.32.139 - - [11/Jul/2007:17:21:46 -0700] 192.168.227.192 - - [11/Jul/2007:17:22:28 -0700] 192.168.128.135 - - [11/Jul/2007:17:22:43 -0700] 192.168.104.11 - - [11/Jul/2007:17:23:45 -0700] 192.168.57.210 - - [11/Jul/2007:17:24:00 -0700] 192.168.115.28 - - [11/Jul/2007:17:24:55 -0700] 192.168.112.24 - - [11/Jul/2007:17:25:11 -0700] 192.168.140.141 - - [11/Jul/2007:17:25:25 -0700] 192.168.100.206 - - [11/Jul/2007:17:26:31 -0700] 192.168.140.141 - - [11/Jul/2007:17:26:56 -0700] 192.168.172.3 - - [11/Jul/2007:17:27:00 -0700] 192.168.71.179 - - [11/Jul/2007:17:27:43 -0700] 192.168.81.11 - - [11/Jul/2007:17:27:45 -0700] 192.168.40.238 - - [11/Jul/2007:17:27:52 -0700] 192.168.38.255 - - [11/Jul/2007:17:27:53 -0700]
- Miller

In reply to Re: Using Date::Calc with an error log by wind
in thread Using Date::Calc with an error log by eselement

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.