perl -lane 'BEGIN{open(A,"ids2.txt"); while(<A>){chomp; $k{$_}++}} if (defined($k{$F[0]})) {print "$_\t$F[0]\t1"} else {print "$_\tNA\t0"}; ' ids1.txt > aaa.xls