On Sat, 9 Feb 2013 11:06:46 -0600
Chris Stinemetz <chrisstinem...@gmail.com> wrote:

> I would like to only work with the data that has a line with |68| in
> it print that line and then print each subsequent lines in that match
> /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of
> the input data.

OTTOMH,

perl -lne '/\|68\|/ .. /\#END/ && /\|7\|\d+\|\d+/ && print'

For an explanation, look up ".." in perldoc perlop - the flip-flop
operator - it evaluates to true once the first condition (in this case,
the current line matches the regex /\|68\|/ becomes true), and
continues to evaluate to a true value until the second condition is true
(in this case, the current line contains "#END"), at which point it goes
back to false again.  Combining that with a check for the line
containing what you want gets you most of the way there; I think it'll
skip the start & end lines though, so you'll probably want to modify
the last regex to include them.



-- 
David Precious ("bigpresh") <dav...@preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to