in reply to stuck in a hash

you can just do my @keys = keys %hash and then apply the Q&A node How can I find the union/difference/intersection of two arrays? to @keys and @all_ids.

To modify your code, though, i would hash up the array first, and then just use the exists function:
my %all_ids = map { $_ => undef } @all_ids; # note there's multiple w +ays to init this hash while ( my ($key, $value) = each(%hash) ) { printf "the pair (%s => %s) is not in the array", $key, $value unles +s exists $all_ids{$key}; } # or grep instead of while: my @missing_keys = grep( !exists $all_ids{$_}, keys %hash);