while (<>) { chomp if (my $num= /^DESCRIPTION$/ .. /^ENDDESCRIPTION/); next if $num==0 || $num =~ /E/; # skip endpoints print; }