use strict; use warnings; my @issued_commands = qw(that or the other); my @showconfig = qw(this that and the other); my %hits = map {$_ => 0} @showconfig; my @hit; my @extra; for my $issued_CM_command (@issued_commands) { if (exists $hits{$issued_CM_command}) { ++$hits{$issued_CM_command}; push @hit, $issued_CM_command; } else { push @extra, $issued_CM_command; } } my @missed = grep {! $hits{$_}} keys %hits; print "No entry in \@issued_commands for: @missed\n" if @missed; print "No entry in \@showconfig for: @extra\n" if @extra; #### No entry in @issued_commands for: and this No entry in @showconfig for: or