use strict; use warnings; use File::Find; use Mail::Send; my $curtime = time(); find(\&wanted, qw(/home/arjen/test)); sub wanted { # Warning: the ctime field is not really the creation time! # See perlport (File and Filesystems) return if (($curtime - (stat($File::Find::dir))[10])) > 900; return if $_ !~ /\.out$/; open(FILE, "<$_") or die "Cannot open $_: $!\n"; while (my $line = <FILE>) { last if $line =~ /error/; } close(FILE); my $msg = Mail::Send->new(Subject => "Error found!", To => "operator\@datacenter"); my $fh = $msg->open(); print $fh "We found an error in $_!\n"; $fh->close(); print "Mail sent\n"; }
Arjen
In reply to Re: File Search
by Aragorn
in thread File Search
by mikevanhoff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |