in reply to Efficiently processing a file
need to process the file line by line. I originally had something like this:... foreach $line (<FILE>) #main loop {
foreach works on lists so it reads the entire file into a list in memory and then iterates through the list. To properly read just one line at a time you need to use a while loop instead:
while ( my $line = <FILE> ) #main loop {
I am guessing that the while(<>) takes from @ARGV and not the values that I pass into the function
Yes, this is coorect. The <> operator is special in that it reads through all the files in @ARGV and each file name is removed from @ARGV and put into $ARGV while that file is being processed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficiently processing a file
by Anonymous Monk on Jan 25, 2010 at 22:37 UTC | |
by rkrieger (Friar) on Jan 26, 2010 at 07:51 UTC | |
by jwkrahn (Abbot) on Jan 25, 2010 at 22:45 UTC | |
by Anonymous Monk on Jan 26, 2010 at 17:03 UTC |