my %hash = map { split /#/ } @array2; for (@array1) { next if !exists($hash{$_}); print("$hash{$_} = $_\n"); }