in reply to LWP and TokeParser

I just want to utter the Perlmonk matra: Use strict warnings and diagnostics or die.

Another thing that will help you is spacing out and indenting your code - especially conditional loops such as your while loop.