in reply to How do you read the next line in a file while in a loop?

Maybe you are missing something or maybe I am. To read a line from INFILE in Perl use $line = <INFILE>; You don't need the readln() in your sample just use <INFILE>.

HTH --traveler

Replies are listed 'Best First'.
Re: Re: How do you read the next line in a file while in a loop?
by GroundZero (Initiate) on Aug 31, 2001 at 02:37 UTC
    Thanks, traveler. I maybe missing something but I don't I want to load a file that could be 50 MB into a string. Am I thinking incorrectly here?
      You are not reading the entire file. <> reads a line at a time just as it does in your while. (Perhaps that is why it is called the "line input operator" <grin>) In array context it can read the entire file into an array, but in scalar context it reads a line. It looked as though your file was multiple lines (based on seeing your while and your wished-for readln). If it is, then this should work.

      HTH, --traveler