Others have suggested various methods for parsing your logfile, to which I would add a suggestion to try looking at substr, especially if you're not yet totally comfortable with regular expressions and the uses thereof (and assuming that your records are fixed-width).
You don't say if you're planning to generate this table dynamically or to store it: if you're doing it on the fly, then I hope you're using CGI.pm, and if you are I suggest outputting the table the easy way, using the Tr and td functions.
If you have a row of data in an array variable (say, @foo), you can generate table cells for that row with the statement
and the Tr function can be used similarly.my $html = td (\@foo);
So the relevant section of your code could look something like this highly off-the-cuff and untested fragment:
my @rows; while (<LOGFILE>) { my @data; #your routine of choice to split the input into fields #and stash it in @data push @rows, td(\@data); } print table (Tr (\@rows));
Which, as you see, makes the whole formatting question pretty much go away.
If you're not doing this dynamically, you could still use the CGI module (use CGI qw (:all -nodebug), but there are probably simpler solutions available on CPAN (try looking under the WWW section for HTML building solutions).
In reply to Re: How to parse a logfile to a HTML table format
by ChemBoy
in thread How to parse a logfile to a HTML table format
by Suwen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |