Here's something simple:
open(FILE, "/export/home/me/filename");
while ($line = <FILE>)
{
# whatever
}
FILE is a filehandle, and by defualt it will give you back a line at a time.
You can also put the whole thing into an array by doing this:
@file = <FILE>;
At least, I think that's it. Somebody correct me if I'm wrong.
-----Original Message-----
From: Jon Serra [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: reading a file line by line
Greetings, I am trying to read a text file into a scalar variable line by
line
until EOF or a search test if fullfilled. I have been reading files in like
this:
chomp (@line = `cat filename`);
I do not want to do this beacuse my file is quite large, and there is no
reason
to hog the memory for the little bit I actually want, and second, I do not
want
to make a system call to the unix cat command. TIA Jon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]