Let me see if I correctly understand what this file is trying to represent before trying to give any further advice:

You have, in effect, a hash mapping a name to an array of hashes, where the key to the array is 'pos' (starting at 1, not 0), and the hash inside the array contains 'gc', 'score' and 'present_absent'.

If you parsed each line via something like:

my ($name,$pos,$gc,$score,$presentabsent) = parse($current_line);
you would end up with assignments like:
my @posarray; my %clsdata; $posarray[$pos] = { 'gc' => $gc, 'score' => $score, 'present_absent' = +> $presentabsent }; $clsdata{$name} = \@posarray;

Then you want to loop through all of your %clsdata hashes, and for each one, loop through the posarray, and for each member:

  1. If the key is <= 8 and present_absent is nonzero, set present_absent to 1
  2. If the key is >8, check the present_absent values for all keys from key-8 to key+8, and if they are all nonzero, set the present_absent value for that key to 1 (question: what do you do when key > $#posarray-8?)
  3. If the key == $#posarray and the value is 0, then set the value of key-8 to 1, otherwise leave it alone.

Is that about what you're looking to do? Can you be more specific about exactly which part you're having trouble with?

Update: Or, grandfather can completely solve your problem while I'm still working out what the question is, heh.


In reply to Re: Hash_of_Hash_Would do it? by AZed
in thread Hash_of_Hash_Would do it? by sesemin

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.