use warnings; use strict; my @terms = qw( Maple Oak walnut pine juniper ); my $text; { #slurp the whole file local $/; $text = ; } if ( $text =~ /upperboundary(.+)lowerboundary/s ) { $text = $1; print $text, "\n\n"; } else { die "no match"; } foreach my $term (@terms) { if ( $text =~ /($term)/is ) { print "$1\n"; } } __DATA__ upperboundary The book Hiking the Red, A Complete Trail Guide To Kentucky's Red River Gorge made it a point to describe the habitat and the diverse species of trees that one is likely to encounter at the Red. According to the authors, the species of trees found in the Daniel Boone National Forest includes beech, sugar maples, white pines, hemlock, several types of oak, and hickory. These trees provide habitat for an estimated 67 different species of reptiles and amphibians, 46 species of mammals, and 100 species of birds. lowerboundary