my $start = 'banana'; my $end = 'grape'; my $get = 0; my @results; open FILE, "file.txt"; while () { chomp; $get = 0 if $_ eq $end; push @results, $_ if $get; $get = 1 if $_ eq $start; } print $_,"\n" for @results;