hiya, I am trying to write code that compares the total count of each of the letters in a line and stores the most common in $consensus.
$Acount = 4; #I have set these values $Ccount = 3; #eventually they will come #from the program looking at #a line in a file $i=0; $j=1; #############WHICH SCORE IS HIGHEST ?############# @scoring = qw ($Acount $Ccount $Dcount...more letters here); @con = qw (A,C,D...more letters here); print "$scoring[$i] \n"; print "$scoring[$j] \n"; if ($scoring[$i]>$scoring[$j]) { $consensus = $con[$i]; $score = $scoring[$i]; } print "consensus is $consensus with a score of $score \n";
eg. I want this to recognize $Acount is higher than $Ccount and store the letter A in $consensus. However when I print out $scoring[$i] and $scoring[$j] I was hoping to see the numbers 4 and 3 printed, not $Acount and $Ccount.

Should I be using an associative array or something, or is this approach just not gonna work ? Thanx

basm100

Edit by dws to add more <code> tags


In reply to values within arrays 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.