in reply to print line 5 lines previous to comaprison line!

Something like this should work
open X,"<$file"; @rows = <X>; close X; for($i=0;$i<$#rows;$i++) { if($rows[$i] =~ /something/) { print $rows[$i-5]; } }

Replies are listed 'Best First'.
Re: Re: print line 5 lines previous to comaprison line!
by davorg (Chancellor) on Jun 07, 2001 at 17:08 UTC
      (I cleared this post. Note to self: never post when hungover)

      Update:I agree, it's wasteful
Re: Re: print line 5 lines previous to comaprison line!
by pat (Initiate) on Jun 07, 2001 at 18:48 UTC
    when I was opening the file it would not open as you had written above so I changed to open (X, $inputfile); and it opened fine and did what it was meant to do thanks but i have seen this before where the syntax you used to open the file did not work, have you seen this and any idea why it is so thanks once again! Pat ( go raibh mile maith agat)