foreach my $logrecord (@errorcheck) { my $errorcount; open (LOGFILE, $logrecord); while () { if(/$error/) { $errorcount++; } } print "$logrecord: $errorcount\n"; if($errorcount != 0) { system ('page Mike "An error was encountered processing file $logrecord. Check the HelpDeskLog\ERRORS dir for more information."'); #last; here if you don't want to bother Mike more than once }