in reply to finding sequence

        if ($tmp1[0] =~m/ *$tmp2[0]*){

Your match pattern isn't terminated. Perl tells you this:

$ perl 1217240.pl Search pattern not terminated at 1217240.pl line 29.

Why the random indentation? It makes your code so hard to read. I'm also mildly intrigued as to why every other line is blank.