Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
Line 1 blah blah blah Line 2 blah blah blah ... Line 1000 blah blah blah Line 1001 --start foo-- [lots of stuff I do need to process] Line 2000 --end foo--
So my probably not-very-programmerly instinct is to just do this:
my $interesting_bit = 0; while(<FILE>){ if(/--end foo--/){ $interesting_bit = 0; last; ## assuming only one interesting ## bit per file of course } if($interesting_bit == 1){ ## do my processing on the lines } if(/--start foo--/){ $interesting_bit = 1; # we've found the line which says # the next line needs to be processed } }
It works for me, but is that bad practice?
Doing it this way seems quick and straightforward once you've got the order sorted out, but rather clunky -- what do other monks think?
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Files for the Interesting Bit
by borisz (Canon) on Jul 05, 2004 at 00:24 UTC | |
|
Re: Parsing Files for the Interesting Bit
by Zaxo (Archbishop) on Jul 05, 2004 at 00:46 UTC | |
|
Re: Parsing Files for the Interesting Bit
by dws (Chancellor) on Jul 05, 2004 at 01:03 UTC | |
|
Re: Parsing Files for the Interesting Bit
by Cody Pendant (Prior) on Jul 06, 2004 at 21:12 UTC |