Individual transactions should probably not be stored in an array, since there is no easy way to find the stored transaction data when you next see a log line about it, and need the info.
If you have unique identifiers for each transaction (which you must), and they are not simple small sequential integers (which I'm sure they aren't), then a hash is the way to go.

For example, you could scan through the log, and everytime you see an event for transaction $Tname, you reference $transactions{$Tname}, to find your notes on what you have seen about it so far.

A hash of hashes of (scalars with a few lists mixed in) would be what I expect. Something like:

$transactions = { transactionOne => { startTime => 123, userName => 'Bob', endTime => undef, foosMunged => [1, 5, 99], } transactionTwo => { ... } };
Note: $transactions{transactionOne}{endTime} being undef, since you haven't seen the end yet, and do not know what the value should be.

Fill in the transaction data as you see it, and once you see the end of a transaction, you can do whatever you need to do with the data you've collected, then delete the hash entry or leave it for later (Given huge files, deleting the old info is probably best). By the time one transaction ends, a few others will be partially populated, but stored safely out of the way behind their own ID keys.


In reply to Re: Interlaced log parser by SuicideJunkie
in thread Interlaced log parser by tzen

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.