Since the time information inside of your files seems to be in a good enough form that you could compare them directly with a string comparison, you could do something like this:
Update: I had a numeric comparator where clearly a string comparator is warranted and fixed the problem with the 12 hour ago timestamp. Thanks neilwatson, japhyuse POSIX qw/strftime/; # generate a timestamp of 12 hours ago in the same format as the data +file $twelve_hours_ago = strftime("%Y-%m-%d/%H:%M:%S",localtime(time-12*360 +0)); while (<FH>) { next unless /PASS/; # skip the non-PASS entries my ($date) = /^([^.]+)/; # grab the date up to seconds next unless $date gt $twelve_hours_ago; # process the interesting records. }
Update #2: While I'm thinking about it, note that this solution probably breaks at DST boundaries.
In reply to Re: Parsing timestamps
by duff
in thread Parsing timestamps
by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |