Hi Monks, I am new to Perl and have been writing a text based log file scanner. It has been fairly straightforward to produce something quickly until now where I have a requirement to implement an other than rudimentary structure from the log data . I am at a decision point as to whether to continue with Perl or not and to complete this using a compiled language.

The problem I have is that I am attempting to build up a structure at runtime using hashes. The log itself is implemented in my Perl script as a hash whose keys are from the root column below. I want each root key value to be a hash of parent keys associated with the root key. Current keys have a similar hierarchical relationship with parent values and have a hash with duration and function name keys associated with them. I need to get at the duration and function name for any root, parent, current key. I need to navigate down the tree from the root to get at these values and want to read the file line by line at runtime and build the structure simultaneously.

I could write this in C++ or C or any compiled language where there is explicit memory allocation, variable initialisation and I could use pointers/references to make it perform etc. I would prefer to complete it in Perl, if possible. The data below is not the real data but is fairly representative of the type of thing I can expect. The keys especially are much longer strings and can contain both alphas and numerics.
@lines = ( # ?, root , parent, current, duration, function name # 0, 1 , 2 , 3 , 4 , 5 ["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" ] ) ;
I am using the ActiveState version of Perl on win2K but the program will eventually run on Solaris. A previous version I have developed in this way is currently running.

Am I using the right tool for this in Perl? I have some sample test code and output, would it be of any use if I posted this too?
Can someone offer some help or direction to some help.

Thanks
Pat

Edit by castaway, added code tags


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