in reply to Re: Problems in dates and time additions by one minute
in thread Problems in dates and time additions by one minute

Thanks for every one for helping me. The reply form "TJPride" has solved my problem, Thank you very much. Now i can further modify it. Could you please explain me these lines a bit more.
for (split /\s+/, $6) { $results{$ts}++ if uc $_ eq uc $word; for $ts (sort { $a <=> $b } keys %results) { ### Start date / time (00) $d1 = [localtime($ts)]; $d1 = $months[$d1->[4]] . sprintf(' %02d %02d:%02d:%02d', $d1->[3], $d1->[2], $d1->[1], $d1->[0]);

Replies are listed 'Best First'.
Re^3: Problems in dates and time additions by one minute
by graff (Chancellor) on Dec 20, 2011 at 04:05 UTC
    What in particular is not clear to you in these snippets?

    In the first part, $6 contains whatever was matched by the 6th set of parens in the previous regex match (basically, everything in the log entry following the time stamp string), $ts is the "seconds since the epoch" time-stamp that corresponds to the matched time stamp string in the log entry, and the if statement returns true on any case-insensitive match of a "word" token from the log entry to the target $word.

    The second part is a loop over hash keys that are being sorted numerically. The first line in the loop creates an array ref containing the list of values returned by localtime, and then uses selected values from that array to create a string that is formatted the same way as the original log entry time stamp string.