in reply to Re: Find the text
in thread Find the text

I am trying using the below method.. Not yet completed... I just collected half an hour details with my system time and i need to find using this.
my $time=0; while ($time <= 1800) { my ($sec,$min,$hour,$day,$month,$year) = localtime(time()-$time); $year = $year+1900; $month++; if ($hour >12) {$hour=$hour-12;} my $date=sprintf "%d/%d/%d %d:%02d:00", $month, $day, $year, $hour, $m +in; push(@array, $date); $time+=60; }

Replies are listed 'Best First'.
Re^3: Find the text
by mzedeler (Pilgrim) on Jul 30, 2009 at 10:16 UTC

    It looks like you are trying to iterate over all whole minutes in a 30 minutes interval. That solution is very ineffective.

    If you have two dates, one from your file and one from the system time, just ensure that they are unix time (seconds since 1/1/1970 00:00) and then subtract one from the other and then see if the result is between 0 and 1800. This is the criteria that decides if a given FIND line is taking place within the next half hour.

    System time is already in unix time, so all you need is converting the time stamps from the file to seconds since epoch. There are plenty of modules that can do it for you.

    Also, please do this:

    • use warnings;
    • use strict;
    • Indent your code.