I need to get at the duration and function name for any root, parent, current key.

If I understand you correctly, you are starting with a 2-D array (a flat table) such that in each row of 6 columns (0-5): column 0 is meaningless, columns 1-3 combine to make up a primary key, and columns 4 and 5 are the data of interest for each primary key.

If all rows are unique in terms of the tuples formed by columns 1-3, then you really only need a simple hash, using the concatenation of these three fields as the hash key -- e.g., building on Zaxo's example:

my %table; while (<DATA>) { chomp; my @line = split /,/; my $key = join ",", @line[1..3]; if ( exists( $table{$key} )) { warn "oops -- duplicate key $key... is there a problem with th +at?\n"; next; # just in case there's a problem with that } $table{$key} = join ",", @line[4,5]; } # later on, if you really need the individual columns from the # hash key or the hash value, just use "split /,/" as needed # <update> # note that you can easily search for groups of hash keys: my @root23keys = sort grep /^23,/, keys %table; my @r23p34keys = sort grep /^23,34,/, keys %table; # and so on... </update> __DATA__ 1,2,3,4,100,A 10,20,30,40,200,B 11,21,31,41,300,C 12,22,32,42,400,D 13,23,33,43,500,E 13,23,33,53,600,F 13,23,33,63,700,G 13,23,34,73,800,H 13,23,34,83,900,I 13,24,35,93,1000,J 13,24,36,103,1100,K

In reply to Re: Hashes by graff
in thread Hashes by flemi_p

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.