in reply to Re: Problem Parsing Log Files
in thread Problem Parsing Log Files

Hi Jethro

It's not an assignment. This script is for production logs. I don't just need a timestamp and count. I want time-stamp, error and count as a I mentioned in desired output. It's not necessery to do it with 2D array. As I need to store 3 components timestamp, error and count. I am not sure of what structure would be best to do this and how to do it.

Thanks,

Ajay

Replies are listed 'Best First'.
Re^3: Problem Parsing Log Files
by jethro (Monsignor) on Jun 18, 2009 at 00:43 UTC

    If you use a hash of arrays as suggested above, the size of the array is your error count, the timestamps are stored in the array, and the error is the key of the hash.

    How to use a hash of arrays is described in the perl5 book for example, or in the manpage perldsc.

Re^3: Problem Parsing Log Files
by dsheroh (Monsignor) on Jun 18, 2009 at 10:40 UTC
    I would go with HoA, given the description of the problem so far. The hash would use error messages as its keys, with references to two-element arrays (latest timestamp, count) as its values.

    Alternately, you might find it easier to just push timestamps onto the arrays. The size would then be the count and (assuming a sorted input file) the last-added timestamp would be the most recent.