in reply to Skip and Scan Lines

You could try to use a do {  } while <LOG> loop instead of the second while (<LOG>) {  }.

Replies are listed 'Best First'.
Re: Re: Skip and Scan Lines
by Anonymous Monk on Mar 18, 2004 at 22:27 UTC
    Thanks for your suggestion! Would yo uplease give me a little bit more details? I would very appreciate it!

      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 $_.
        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!