Re: reading a file line by line

2002-03-04 Thread Hernan Freschi
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

Re: reading a file line by line

2002-02-27 Thread John W. Krahn
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

RE: reading a file line by line

2002-02-27 Thread Lyon, Justin
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

Re: reading a file line by line

2002-02-27 Thread Brett W. McCoy
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