in reply to Parsing timestamps
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing timestamps
by neilwatson (Priest) on Nov 04, 2005 at 16:01 UTC | |
|
Re^2: Parsing timestamps
by japhy (Canon) on Nov 04, 2005 at 16:21 UTC |