in reply to Reading a pattern and a number of lines after it

With a pattern of /ou/ and numlines set to 3 I get:
perl -ne '$x=/ou/..0; print if $x && $x-1 <= 3' data.dat
As in:
% cat data.dat one two thrtestee four five six werwr werwer seen? % perl -ne '$x=/ou/..0; print if $x && $x-1 <= 3' data.dat four five six werwr
Notice how it prints the matching line plus an additional $numlines lines...

-Blake

Replies are listed 'Best First'.
Re: Re: Reading a pattern and a number of lines after it
by simon.proctor (Vicar) on Jan 09, 2002 at 05:13 UTC
    thanks :)

    Looks like I have still got quite a few tricks to learn!