in reply to Finding part of a file
You'd need something a little more subtle if you aren't sure that 'banana' comes before 'grape' or you think one or other might be absent altogether.my $start = 'banana'; my $end = 'grape'; my $get = 0; my @results; open FILE, "file.txt"; while (<FILE>) { chomp; $get = 0 if $_ eq $end; push @results, $_ if $get; $get = 1 if $_ eq $start; } print $_,"\n" for @results;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding part of a file
by Aighearach (Initiate) on Dec 04, 2001 at 21:02 UTC |