Fix this to taste - it's my best guess at what you need. It reads one header per file and then multiple records per file.

use strict; use warnings; use constant HEADER => q[ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +"> <style type="text/css"> <!-- body { font-family: verdana; font-size: 7px; } tbody { font-family: verdana; font-size: 9px; } --> </style> </head> <body> <TABLE width=955 cellPadding=1 cellSpacing=0> <TBODY> <TR vAlign=top> <TD width="59" height=16> <P class=Table>File Name, &nbsp;&nbsp; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P></TD> <TD width="68" height=16> <P class=Table>Author,&nbsp;&nbsp;&nbs +p;&nbsp;&nbsp; </P></TD> <TD width="144" height=16> <P class=Table>Date (MM/DD/Year),&nbs +p;&nbsp;&nbsp; </P></TD> <TD width="96" height=16> <P class=Table>TIME (H:M:S),&nbsp;&nbs +p;&nbsp;&nbsp;&nbsp;&nbsp; </P></TD> <TD width="114" height=16> <P class=Table>Version No.,&nbsp;&nbs +p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P></TD> <TD width="59" height=16> <P class=Table>Number,</P></TD> <TD width="97" height=16> <P class=Table>Feature Name,</P></TD> <TD width="125" height=16> <P class=Table>Paragraph Number,</P>< +/TD> <TD width="173" height=16> <P class=Table>Requirement Number</P> +</TD> </TR> ]; use constant FOOTER => q[ </TBODY> </TABLE> </body> </html>]; sub fixupRecord { my $record = shift; for (qw(FileName Author Date Time Version Number FeatureName ParagraphNumber RequirementNumber)) { $record->{$_} = '&npsp;' unless defined $record->{$_} } } sub formatRecord { my $record = shift; fixupRecord( $record ); qq[ <TR vAlign=top> <TD width="59" height=16> <P class=Table>@{[$record->{FileName}] +}</P></TD> <TD width="68" height=16> <P class=Table>@{[$record->{Author}]}, +</P></TD> <TD width="144" height=16> <P class=Table style="MARGIN-TOP: 0px +; MARGIN-BOTTOM: 0px">@{[$record->{Date}]}</P></TD> <TD width="96" height=16> <P class=Table style="MARGIN-TOP: 0px; + MARGIN-BOTTOM: 0px">@{[$record->{Time}]}</P></TD> <TD width="114" height=16> <P class=Table style="MARGIN-TOP: 0px +; MARGIN-BOTTOM: 0px">@{[$record->{Version}]},</P></TD> <TD width="59" height=16> <P class=Table style="MARGIN-TOP: 0px; + MARGIN-BOTTOM: 0px">@{[$record->{Number}]},</P></TD> <TD width="97" height=16> <P class=Table style="MARGIN-TOP: 0px; + MARGIN-BOTTOM: 0px">@{[$record->{FeatureName}]}</P></TD> <TD width="125" height=16> <P class=Table style="MARGIN-TOP: 0px +; MARGIN-BOTTOM: 0px">@{[$record->{ParagraphNumber}]},</P></TD> <TD width="173" height=16> <P class=Table style="MARGIN-TOP: 0px +; MARGIN-BOTTOM: 0px">@{[$record->{RequirementNumber}]}</P></TD> </TR> ]; } print HEADER; for my $filename (@ARGV) { my $file = do { local (@ARGV, $/) = $filename; <> }; my %record; for ([ Author => qr/^Author\s+:\s+(.+)/m ], [ Number => qr/^Number\s+:\s+(.+)/m ], [ Version => qr/^Version Number\s+:\s+(.+)/m ], [ FeatureName => qr/^Feature\s+:\s(.+)/m ], [ FileName => qr/^File Name\s+:\s(.+)/m ], [ Date => qr/^Modification Date\s+:\s(.+)/m ]) { @record{$_->[0]} = $file =~ $_->[1]; $record{$_->[0]} =~ s/^\s+//; $record{$_->[0]} =~ s/\s+$//; } $file =~ s/^.+?Paragraph Number\s+Requirement Number\s+Last Modifi +ed\n//s; for (split /\n/, $file) { my %instance = %record; @instance{qw(ParagraphNumber RequirementNumber)} = split; print formatRecord( \%instance ); } } print FOOTER;
__SIG__ printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B::svref_2object(sub{})->OUTSIDE;

In reply to Re: Converting logs to CSV format (desperate help) by diotalevi
in thread Converting logs to CSV format (desperate help) by pelp

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.