#!/usr/dist/share/perl,v5.003/5bin.sun4/perl use strict; use warnings; use Time::Local qw/ timelocal_nocheck /;; use POSIX qw/ strftime /; my $secs = 3600; # 1 hour my ($s, $m, $h, $d, $mon, $y) = localtime; my $time_ago = strftime "%Y/%m/%d %H:%M:%S", localtime timelocal_nocheck $s - $secs, $m, $h, $d, $mon, $y; print "$time_ago was one hour ago\n"; my $mailprog = "|/usr/sbin/sendmail -t"; my $lst_email = 'someone@outthere.com'; # DATA should be saved as the spaecial filehandle # for self-contained programs (like this one) #open (my $in, "/mylist.log") || die ("Can't Open data File: $!\n"); # while (<$in>) { while () { chomp; my ($datestamp, $status, $location) = split /\|/; if ($datestamp lt $time_ago && $status eq 'red') { # do email notification print "red for more than an hour\n$_\n"; } } __DATA__ 2011/04/12 12:50:24|red|florida 2011/04/12 15:20:21|green|tampa 2011/04/12 15:30:12|red|miami