open (FILE, '<', '123.log') or die "Could not 123.log: $!"; my $i=0; while () { #print $_ if (/^[==========]/ .. /^tests./); if (/^[0-9] tests from [0-9] test cases ran/ .. /^[0-9] tests\./){ print "$i.Match Found:".$_."\n"; $i++; } }