in reply to Finding part of a file
Expanding on blakem's suggestion, here's what I'd do:
#!/usr/bin/perl -w use strict; my ($start, $end) = qw(banana grape); while (<DATA>) { if (/^$start$/ .. /^$end$/) { print unless /^($start|$end)$/; } } __END__ apple banana pear peach grape orange
Update: Thanks to blakem for pointing out the missing $ on the end of the flip-flop. He also points out that this may be a good place to use the /o option to the match operator and I agree. You should probably benchmark to see how much of a gain you get.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding part of a file
by runrig (Abbot) on Dec 05, 2001 at 03:27 UTC | |
by blakem (Monsignor) on Dec 05, 2001 at 03:53 UTC |