in reply to Re: upto match please, my one-lina!!
in thread upto match please, my one-lina!!

That doesn't print the "---\n" string or the correct lines. You want something like:
perl -ne'@t=(@t[1..4],$_);/regex/&&die@t,"---\n"' file

Replies are listed 'Best First'.
Re^3: upto match please, my one-lina!!
by roboticus (Chancellor) on Jun 09, 2006 at 04:05 UTC
    D'oh!

    I was having so much fun playing with one-liners that I forgot the parameters of the problem. I love that die trick.... I'll have to try it:

    perl -ne '@t=(@t[1..4],$_,"---\n");die@t if/foo/' file
    --roboticus
      @t=(@t[1..4],$_,"---\n")
      You are adding two lines for every one line you remove so every second line will be "---\n".