use strict; use warnings; my $file = $ARGV[0]; open( my $fh, '<', $file ) or die "Can't open $file: $!"; while ( <$fh> ) { if ( /Error:/i .. /^\s*$/ ) { print; } } close $fh;