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,
+
</P></TD>
<TD width="68" height=16> <P class=Table>Author, &nbs
+p;
</P></TD>
<TD width="144" height=16> <P class=Table>Date (MM/DD/Year),&nbs
+p;
</P></TD>
<TD width="96" height=16> <P class=Table>TIME (H:M:S), &nbs
+p;
</P></TD>
<TD width="114" height=16> <P class=Table>Version No., &nbs
+p;
</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;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.