foreach (@commands_run){ if($_ =~m/clock/) { print "\n Test -- found pattern -- \n";} else {print "\n Test -- did not find pattern -- \n";} }