in reply to Re: grab only if pattern matches previous line
in thread grab only if pattern matches previous line

Hi, I should probably clarify a couple things. 1. the data file is large. 2. there is a lot of useless header information and data I want to skip (some of it messy). 3. It is true that for each case where there is a request(REQUEST_NAME the very next line will always be the START_TIME, so really just incrementing one line past the good requests would work (though it's probably not as safe). 4. the BADSTRING is not the entire string. Thanks!
  • Comment on Re: Re: grab only if pattern matches previous line

Replies are listed 'Best First'.
Re: Re: Re: grab only if pattern matches previous line
by greenFox (Vicar) on Jul 11, 2003 at 02:36 UTC

    If your data file is really large then you should work on the data as you slurp it. I used an array because that is what your sample code used :)

    while(<FILE>){ next if /^matches messy header/; chomp; if (/matches some string/){ my $next_line = <FILE>; # do something to $next_line here print "$_, $next_line\n"; } }

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho