sub compare_arrays { my ($first, $second) = @_; my %found=map{($_,1)}@$first; my @tmp; for my $elm (@$second) { if(defined($elm) && $found{$elm}) { push(@tmp,$elm); } } return @tmp; }