#strictures - put these two lines at the top of every Perl script #these do a lot of the debugging work for you use strict; use warnings; ... lots of other stuff ... # do: awk '/fileid/,/^-----/' logfile | grep specificdata my $bPrint=0; open LOGFILE, '<', "Monks/tmp/logfile.txt" or die; while (my $line = ) { #equivalent to awk '/fileid/,/^-----/' logfile $bPrint = 1 if $line =~ /fileid/; $bPrint = 0 if $bPrint && $line =~ /^-----/; #equivalent to grep specific data print $line if $bPrint && $line =~ /specificData/; } close LOGFILE;