There's a simpler way, if you specify the file from the command line (as in
script.pl file) you can do
while (<>) {
last if /search test/;
#do something
}
in fact, you can make a cat-like script like this:
while (<>) {
print;
}
<> is the diamond operator, and it's the filehandle fo
Jon Serra wrote:
>
> 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
#x27;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 lin
On Wed, 27 Feb 2002, Jon Serra wrote:
> 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
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