Your sample data says you have five fields but your code says you have six fields?   So which is it?

# then go thorough $hash_F2_2 and that has the key (origin) # and max as value and make a multivalue hash as follows: for my $k (sort keys %hash_F2_2){ my $v = $hash_F2_2{$k}; #print RESULTS "$k\t$v\n"; for (my $i=1; $i <= $v; $i++){ push (@{$hash_F2_3{$k}}, $i); # this hash (%hash_F2_3) is the hash of origins and PIPs from +1 to max } }

You don't need the inner foreach loop, you can just use the range operator.   And if you remove the loop then you don't need to use push either.   And you don't really need the %hash_F2_2 hash either:

# then go thorough $hash_F2_1 and that has the key (origin) # and make a multivalue hash as follows: my %hash_F2_3; for my $k ( sort keys %hash_F2_1 ) { #print RESULTS "$k\t$hash_F2_1{ $k }\n"; @{ $hash_F2_3{ $k } } = 1 .. max @{ $hash_F2_1{ $k } }; # this hash (%hash_F2_3) is the hash of origins and PIPs from 1 to + max }

In reply to Re^3: Complex Data Structure by jwkrahn
in thread Complex Data Structure 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.