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
Here's something simple:
open(FILE, "/export/home/me/filename");
while ($line = )
{
# 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 = ;
At least, I think that's it. Somebody corre
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