in reply to Re^3: Logfile to HTML and MIME EMail table
in thread Logfile to HTML and MIME EMail table

Hi loops, When I use this line below:
Line 25: $Wtable->addRow(split(/\s\s+/, $Wlog->readline)) for (1..24);
it gives me the error while compiling:
Use of uninitialized value in split at table.pl line 25. Use of uninitialized value in split at table.pl line 25. Use of uninitialized value in split at table.pl line 25.
This is dependent on the input file? The input file contains:
Tue Jul 23 14:23:20 2013 17628 KB 4030 KB 77% Tue Jul 23 14:23:20 2013 17628 KB 4030 KB 77% Tue Jul 23 14:23:20 2013 17628 KB 4030 KB 77%
the split looks ok and the output is fine but somehow this errors come up.

Replies are listed 'Best First'.
Re^5: Logfile to HTML and MIME EMail table
by Loops (Curate) on Jul 24, 2013 at 01:08 UTC
    Yeah, it's complaining because the HTML table expects 7 elements and is only getting 4. I'm sure there is better code to fix this up, but here is a quick fix to ensure that addRow always gets 7 defined elements:
    $Wtable->addRow(map { $_ // "" } (split /\s\s+/, $Wlog->readline)[0 .. + 6]) for (1..24);

    Note that this will mean any lines containing more than 7 elements will be truncated.

    Updated for brain fart