http://www.perlmonks.org?node_id=656828

wruehl has asked for the wisdom of the Perl Monks concerning the following question:

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]; }
-Bill