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.
In reply to Re: Efficiently processing a file
by jwkrahn
in thread Efficiently processing a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |