in reply to Re: Re: Skip and Scan Lines
in thread Skip and Scan Lines

When the first loop finds the first line you wants to process, it exits with the line still being in $_. Then the condition of the second while loop reads the next line to $_ thus discarding the first one. You should write

while (<LOG>) { ... processing log line .... }
to
do { ... processing log line .... } while <LOG>;
Because of the special way perl handles do {} while, the condition is evaluated only after the body has run first, so the body processed the line that's still in $_.

Replies are listed 'Best First'.
Re: Re: Re: Re: Skip and Scan Lines
by jc7 (Initiate) on Mar 22, 2004 at 19:08 UTC
    Thanks for your suggestion! I tried it but it did not work as I expected. I am not sure where I did wrong. Using the suggestion from graff, I have made it works.

    Thanks you all for your help! Your folks are really good and helpful!