use warnings; use strict; my $success = 0; open(FILE, "<", "dumptape.log") or die "Couldn't open dumptape.log: $!"; while () { if (/Dump phase number 3/) { # We found the line my $line = ; # read the next line print $line; # print the next line ; # Skip a line ; # Skip a line $line = ; # read the fourth line print $line; # print the fourth line $success = 1; # we found it last; # So we're done! } } close FILE; if (! $success) { print "Failed dump log\n"; }