in reply to Re: trying to do a parse based on starting position.
in thread trying to do a parse based on starting position.
The trigger is armed when and only when the trigger condition hasn't (yet) been hit... so no additional requirement as you suggested in closing :-)use strict; my $trigger = -1; while (<>) { $trigger = $. + 2 if $trigger != -1 && /^LUN 40\s*$/; # Changed: # print if $. == $trigger; # To: print, last if $. == $trigger && /^LUN 40\s*$/;
Update
Hmmm, having read the question again (and not got as far as ikegami et al's posts which would have told me that), the OP wants only the line in question, not the line c/w all following, hence the solution is easier still...edited accordingly.
|
|---|