# Determines if two hashes have different keys # If the hashes are different: # In list context returns two array refs, each # containing the missing elements from the other # In scalar context returns an AOA, with a similar # content as above # Otherwise # Returns the empty list or undef as appropriate. # Thus # A true return means they hashes are different, # a false means they have identical keys sub hash_key_diff { my ($x,$y)=@_; my (@x,@y); foreach my $k (keys %$x) { push @y,$k unless exists $y->{$k}; } foreach my $k (keys %$y) { push @x,$k unless exists $x->{$k}; } return @x||@y ? wantarray ? (\@x,\@y) : [\@x,\@y] : () }