Fishing out error message within a log file

Hi all,

i have a log file that captures success or failure messges when i run a daily job.
here is a sample of my log.

20060312 start
successful
successful
failure
failure
20060312 end

i need to write a subroutine that opens up the log daily after my job completes to examine the log and if there are failures alert me.

##########
script that perform the job. print out current time,records success or failure. when job ends, 
print out time when job started. 
###########
a small routine to open up the log, 
count number of times 'failure' appears demarked by the start and
end text and if count >1 email myself with the lines of failure.

how can i do it in perl? i am thinking along the line of storing the start and end line in two variables, open up the log, filter out the chunk of lines within the 2 variables and do a count. Any suggestions?

What means the number 20060312 before start/end?

The script below reverses logfile then searches text between end and start:

#!/usr/bin/perl -w

open (INPUT, "< logfile");
for (reverse <INPUT>) {
    if (/end/ .. /start/) {
        last if /start/;

        if (/failure/) {
##################################
# failure detected: do hear what you want, e.g
            print 'FAILURE';
#################################
            last;
        }
    }
}