I'm trying to create a non uniform multi-dimention array with push.

The purpose is to create an array holding a histogram of error lines in a component log file.

For example:

Say I have a LOGFILE that I need to filer only the error messages out of it, but divide the times into groups, like: if the LOGFILE contain entries of 2 hours from 00:00:00 till 02:00:00, I need to check in every 10 min in that time period, how many error messages appeared and from which type.

Therefore, for example I have 4 error types in an array, like "File not found", "File is empty", "Wrong permissions", "object is not a file", respectively as 0..4 .

I'm trying to create the following structure:

+------------------+---------------+------------------+ | Error Type index | Time interval | Number of errors | +------------------+---------------+------------------+ | 0 | 00:00:00 | 1 | | | 00:10:00 | 5 | | | .... | .... | | | 01:50:00 | 7 | +------------------+---------------+------------------+ | 1 | 00:00:00 | 21 | | | 00:10:00 | 34 | | | .... | .... | | | 01:50:00 | 11 | +------------------+---------------+------------------+ | | .... | .... | +------------------+---------------+------------------+ | 3 | 00:00:00 | 0 | | | 00:10:00 | 0 | | | .... | .... | | | 01:50:00 | 17 | +------------------+---------------+------------------+

In this way, the 1 column size is 4, the 2nd and 3rd columns sizes are 12.

I'm filling the data when reading the LOGFILE line by line and consider that this array doesn't exist and I need to create it using push.

Is there any effective way of doing this in the right way?

Thanks


In reply to How to create a non uniform multi-dimention array with push? by shaialo

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.