Majian wrote:
Hi,all:
I have the text like this:
xxxx
xxxx
xxx sum = 1,
xx
xx
xx
d_bits
xxx
xxx
xx  sum =0
xx
xx
xx
d_bit
xx

My question is : How can I read the nextline after the d_bits if sum = 1?

$ echo "xxxx
xxxx
xxx sum = 1,
xx
xx
xx
d_bits
x1xx
x2xx
xx  sum =0
xx
xx
xx
d_bit
xx
" | perl -ne'/sum\s*=\s*(\d+)/ and $sum = $1; print scalar <> if /d_bits/ && $sum == 1'
x1xx




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
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