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 = ) { 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"; }