{ local $/ = 'Time:'; while(my $record = <$fh>) { # Skip over everything that doesn't have ESME_RTHROTTLED next unless $record =~ /ESME_RTHROTTLED/; # If we made it here, then this is a record that matches. # ... so do something with it ... } }