Lance Prais wrote:
>
> I am using the following code to parse through a log file and match words on
> two sequential lines. I would like to add some code to it to check three
> sequential lines. I have tried several things but with not luck. Could
> someone please take a look at the code at let help me with this.
>
> #/usr/bin/perl
#/usr/bin/perl -w
use strict;
> #open a file with the filehandle
> open WORKFLOW, "+<..\\..\\workflow.txt" or die "Cannot open Workflow $!\n";
>
> for(my $i=0; $i<22; $i++){<WORKFLOW>}; #This will put you at row 23.----
<WORKFLOW> for 1 .. 22;
> $_=<WORKFLOW>; #set the var for the first
>line
> my $nextline = <WORKFLOW>; #set the var for the second line
> my $thirdline =<WORKFLOW>; #set the var for the third line
$_ = <WORKFLOW> . <WORKFLOW> . <WORKFLOW>;
> if ((substr($_, 42, 7) eq "Running") and (substr($nextline, 42, 7) eq
> "Running")and (substr($thirdline, 42, 7))
> {
if ( /^.{42}Running/mg == 3 ) {
> open (APPEND, ">>Moniterlog.log") or die "$! error trying to append";
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
> %weekday=(
> "0"=>"Sunday",
> "1"=>"Monday",
> "2"=>"Tueday",
> "3"=>"Wednesday",
> "4"=>"Thursday",
> "5"=>"Friday",
> "6"=>"Saturday",
> "7"=>"Sunday",
> );
my @weekday = qw/Sunday Monday Tuesday Wednesday Thursday Friday
Saturday/;
> if ($hour> 12)
> {
> print APPEND "Successfully Completed Work Flow Moniter
> $hour:$min\n";
> print APPEND 'Substring: '.substr($_, 42, 7);
Since substr($_, 42, 7) is always equal to "Running" (we tested for this
in the if statement above) just print "Running".
print APPEND "Substring: Running\n";
> print APPEND "\n";
> print APPEND 'Substring: '.substr($nextline, 42, 7);
> print APPEND "\n";
> print APPEND "----------------------------------------------------\n";
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]