I'm not sure I understand your question completely. If you want to print your 'found / not found' once, i.e. whether the pattern is present or absent in the array you could either join the array into a string an match the string (just make sure you don't create a match by joining the elements of the array) or have a flag that indicates a match and print your message after looping over your array.
use strict;
use warnings;
my @commands_run = qw(first second clock fourth);
#join all elements of the array
my $all_commands = join '#', @commands_run;
if ($all_commands =~m/clock/) {
print "\n Test -- found pattern -- \n";
} else {
print "\n Test -- did not find pattern -- \n";
}
#use a flag to indicate a match
my $found = 0;
foreach (@commands_run) {
if($_ =~m/clock/) {
$found++;
}
}
$found ? print "\n Test -- found pattern -- \n"
: print "\n Test -- did not find pattern -- \n";
cheers
si_lence