My First "post"!

I'm getting unexpected (INCORRECT??!!)
results from the "index" function.

I'm looking for enlightenment.

My code and output follow:

#!/usr/bin/perl -w open (IN, "one.seq.one.line"); open (OUT, ">out.index.pl"); while(<IN>){ print OUT $_; print OUT "The first occurance of little a is: ", index($_,"a"), "\n"; print OUT "The first occurance of little c is: ", index($_,"c"), "\n"; print OUT "The first occurance of little g is: ", index($_,"g"), "\n"; print OUT "The first occurance of little t is: ", index($_,"t"), "\n"; print OUT "\n\n"; }
Here is the output

ATGGACTGCACCTGGAGGATCCTCTTCTTGGTGGCAGCAGCTACAGgcaagagaatcctgagttccaggg +ctgatgaggg The first occurance of little a is: 48 The first occurance of little c is: 47 The first occurance of little g is: 46 The first occurance of little t is: 49
Note that the last line does NOT give the position of
the first little t (should be 55).
Also note that if I change the order in the code so
that the I put the index($_,"t") line first
(before the other three), then it gives the correct
results.

Thanks much!
Would anyone be willing to use my exact code and
put the above line (starting with ATG...) into
the file "one.seq.one.line", and see if they get
the same results as I did???

I'm an admitted newbie, but my systems administrator
looked at if for about 15 mins this morn and thought
it was funny as well.

Thanks much!!

In reply to Funny results of "index" by jkmiller

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.