#!/usr/bin/perl -w use strict; use IO::File; use constant FILE => 'b2bclient-gateway-heartbeat.log'; use constant FIND => 'production'; IO::File->input_record_separator(FIND); my $fh = IO::File->new(FILE, O_RDONLY) or die 'Could not open file ', FILE, ": $!"; $fh->getline; #fast forward to the first match, print each occurence in the file print IO::File->input_record_separator while $fh->getline; $fh->close;