open(R,$s_file); while() { if(/$search/) { chomp; s/\@|\$\{|\}|\(|\)|\*//g; my $match_line = $_; $cnt = grep(/$match_line/, @target); $i++; print "$i $cnt $match_line\n"; $cnt=0; } }