my %k = map {($_, 1)} @y; for my $x (@x) { push @z2, (exists $k{$x}) ? '+' : '-'; }