I'm not sure if I've quite understood your question, but just in case I have:

#!/usr/bin/perl -w use strict; chomp(my @list = grep /^(?:Query|Sbjct) /, <>); s/^\w*\s+\d*\s+([^\s]+).*/$1/ for @list; for my $i (0 .. @list / 2 - 1){ my $mm; my @a = split //, $list[$i*2]; my @b = ('|') x @a; my @c = split //, $list[$i*2+1]; for (0..$#a){ if (uc($a[$_]) ne uc($c[$_])){ $b[$_] = ' '; $mm .= "Mismatch ($a[$_]/$c[$_]) at position " . ($_ + 1) +. "\n"; } } print @a, "\n", @b, "\n", @c, "\n"; print $mm ? "$mm\n" : "\n"; }

Running the above script with your (tweaked to produce errors) file as an argument, the output is

TGtAGTGCAGTGGCGCAATCTCGGCTCACTGCAAGCATCGCCTCCTGGGTTCACGCCATT || ||||||||||||||||||||||||||||||||||||||||||||||||||||||||| TGGAGTGCAGTGGCGCAATCTCGGCTCACTGCAAGCATCGCCTCCTGGGTTCACGCCATT Mismatch (t/G) at position 3 CTCCTGCCTCAGCCTCCCGAGTAGCTGGGACTACAGGCATCTGCCACCATGCCCCACTAA |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| CTCCTGCCTCAGCCTCCCGAGTAGCTGGGACTACAGGCATCTGCCACCATGCCCCACTAA ttttttctattttttAGTAGAGACGGGGTTTCACCATGTTAGCCAGGATGGTCTCGATCT |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| TTTTTTCTATTTTTTAGTAGAGACGGGGTTTCACCATGTTAGCCAGGATGGTCTCGATCT CCTGACCTCGTGATCCGCCCACCTCAGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCC ||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||| CCTGACCTCCTGATCCGCCCACCTCAGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCC Mismatch (G/C) at position 10 aTGTTTTGAGCATATAGGGAAAATTTATAAAAATTGGCCATGATGaaacataagctcaaa |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ATGTTTTGAGCATATAGGGAAAATTTATAAAAATTGGCCATGATGAAACATAAGCTCAAA aagtttaaaaagaaaactcctaaaagttggcataacaaagcctaaaaaTCATTTCAAACT |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| AAGTTTAAAAAGAAAACTCCTAAAAGTTGGCATAACAAAGCCTAAAAATCATTTCAAACT TGGTATAACTGTTACTAGAAAACCATCTACACAATGACTATATATATGCCTTTATTTCAT |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| TGGTATAACTGTTACTAGAAAACCATCTACACAATGACTATATATATGCCTTTATTTCAT TTTTATGTTACGCTTCTCTTTATATTTGAATCATTCCTTTAAACTACATAAACATTTTCA |||||||||| |||||||||| |||||||| ||||||||||||||||||||||||||||| TTTTATGTTAAGCTTCTCTTTCTATTTGAACCATTCCTTTAAACTACATAAACATTTTCA Mismatch (C/A) at position 11 Mismatch (A/C) at position 22 Mismatch (T/C) at position 31 AGTGTTTGTAAATACCCTTTTAAAAATTACTGCTGTTAGCTGTTCTTCATGATTTTCTTA |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| AGTGTTTGTAAATACCCTTTTAAAAATTACTGCTGTTAGCTGTTCTTCATGATTTTCTTA CTGGTCTCCTTACACATTCGAAATTGGACATTTCCGACTATTTCCTTGGTATGTTTTATA |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| CTGGTCTCCTTACACATTCGAAATTGGACATTTCCGACTATTTCCTTGGTATGTTTTATA

I hope that's what you were looking for. :)

Update: Just realized you were looking for every mismatch rather than just the first one. Corrected.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

In reply to Re: finding the position by oko1
in thread finding the position by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.