Thanks for the reccomendation. This is what I have so far, it is mostly cannibalized from a similar reporting scheme. The comparison tags in here are from the original script, I will not be searching for things like dkcHWProcessor in my script.

I just need to figure out how to get the line after something is found, IE the line directly after SA220 Fault report, and place it into the array entry. I also need to be able to check that field and compare to "The array is operating normally." in order to flag for the summary.

use strict; use Time::Local; use File::Basename; use File::Spec; use Cwd; use Getopt::Long; use constant TRUE => 1; use constant FALSE => 0; use MIME::Lite::TT::HTML; use warnings; my $OUTFILE_3 = "/EMC/faults.txt"; my $OUTFILE_5 = "EMCerrors.txt"; my $OUTFILE_6 = "EMCerrorlog.txt"; my $OUTFILE_7 = "EMCmailtxt.txt"; my $OUTFILE_8 = "/EMC/simrc.txt"; # Get the current time and date my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); my $second = undef; my $minute = undef; my $hour = undef; my $dayOfMonth = undef; my $month = undef; my $yearOffset = undef; my $dayOfWeek = undef; my $dayOfYear = undef; my $daylightSavings = undef; ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek +, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$m +onth] $dayOfMonth, $year"; my @TEMP_ARRAY_1 = undef; my @TEMP_ARRAY_2 = undef; my @TEMP_ARRAY_3 = undef; my $SRCHSTR = undef; my $SRCHSTR1 = undef; my $SRCHSTR2 = undef; my $SRCHSTR3 = undef; my $PRTSTR = undef; my %PARAMS; 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/dkcHWProcessor/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA120} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA120} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA120;"; } } if ( $_ =~ m/dkcHWCSW/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA121} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA121} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA121;"; } } if ( $_ =~ m/dkcHWCache/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA122} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA122} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA122;"; } } if ( $_ =~ m/dkcHWSM/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA210} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA210} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA220;"; } } if ( $_ =~ m/dkcHWPS/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA211} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA211} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA221;"; } } if ( $_ =~ m/dkcHWBattery/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $PARAMS{SA212} = $TEMP_ARRAY_2[1]; if ( $PARAMS{SA212} =~ m/noError/g ) { } else { $PARAMS{SUMMARY} = $PARAMS{SUMMARY}= "SA222;"; } } } close F_INFILE_3; if ( $PARAMS{SUMMARY} eq "" ) { $PARAMS{SUMMARY} = "NO ERRORS FOUND"; my $msg = MIME::Lite::TT::HTML->new( From => 'santeam@bla.com', To => 'pbkhk@bla.com', Subject => 'EMC CX HEALTH REPORT:NO ERRORS FOUND', Template => { html => 'EMC.html.tt', }, TmplParams => \%PARAMS, ); $msg->send; } else { $PARAMS{SUMMARY} = "ERRORS FOUND:".$PARAMS{SUMMARY}; my $msg = MIME::Lite::TT::HTML->new( From => 'santeam@bla.com', To => 'pbkhk@bla.com', Subject => 'EMC CX HEALTH REPORT:ERRORS FOUND', Template => { html => 'EMC.html.tt', }, TmplParams => \%PARAMS, ); $msg->send; };
-Bill

In reply to Re^2: Taking information from a text file and inserting it into an html template by wruehl
in thread Taking information from a text file and inserting it into an html template by wruehl

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.