# the values here don't matter, all we really # care about is the existence of the keys my %pro = map { $_, 1 } qw[CMD /bin/sh rds SysExec /oasis/bin/sysmenu /oasis/bin/TS_TextSrvcs]; # get the third column from every line of $syscmd my @list = map { (split " ")[3] } <$syscmd>; # remove the keys of %pro in @list delete @pro{@list}; # print the error message foreach my $not_found (keys %pro) { print "Didn't find $not_found in output of system cmd.\n"; }