as example
it is bad because:
1. it tells nothing if there are no common elements, it's just quietly goes down)
2. presumably arrays don't contain repeating elements themselves, but it should tell;
though it will, if you change the foreach cycle to something like print "$k\n" if $h{$k} >= 2;
@mammals = qw/dog cat mouse horse planet/;
@sky = qw/star planet galaxy nova comet/;
%h = map {$_ => $h{$_}++} @mammals, @sky;
foreach $k (sort keys %h){
print "in both: $k\n" if $h{$k};
}