I've been tasked with taking some output data from a script and putting it into an html report e-mail for our manager. The first step is to be able to parse from the input file, which will have a format as below: I can do things like remove the date and the lines that say Fault report for x . I'm thinking there must be a way to take in a line to memory and then insert it into an html template in a specific location. I'm just not sure how to do it. The once thing I can't change is the extra line that gets printed after The array is operating normally, that is a function of the reporting tool.
Thu Dec 13 07:03:01 EST 2007
Fault Reports for RDC:
Fault Report for SA220:
The array is operating normally.
Fault Report for SA221:
The array is operating normally.
Fault Report for SA222:
The array is operating normally.
Fault Reports for TDC:
Fault Report for SA120:
The array is operating normally.
Fault Report for SA121:
The array is operating normally.
Fault Report for SA122:
The array is operating normally.
I have an HTML template file ready to go. It can be found here:
https://netfiles.uiuc.edu/wruehl/www/EMC.html.tt
I want to be able to pipe in the data from the lines in the text file to the corresponding fields in the html template.
Update: I have some code that is used in a similar manner. If F_INFILE is the input from above, how could I do the search and input like it is done here? I'm not very good with regex stuff, so this looks foreign to me: What is being done here? I know it is going through line by line in the source file, but beyond that I'm not sure, is it searching for a line that contains raidExMibVersion and then piping it to the parameter to be passed?:
open(F_INFILE_3, "< $OUTFILE_3");
open(F_INFILE_8, "< $OUTFILE_8");
$PARAMS{MTIME} = $theTime;
foreach (<F_INFILE_3>) {
chomp $_;
$_ =~ s /^\s//g;
$_ =~ s /\./_/g;
if ( $_ =~ m/raidExMibVersion/g ) {
@TEMP_ARRAY_1 = split("=",$_);
@TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]);
$PARAMS{MV} = $TEMP_ARRAY_2[1];
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.