in reply to Re: Reading from file, not to memory
in thread Reading from file, not to memory
Take a look in this 2 test scripts. They show the file buffer position when you print each line:
OK way:my $file = $0 ; open(FH, $file) ; foreach my $line (<FH>){ my $tel = tell(FH) ; print "$tel>> $line" ; } close FH;
You can see that in the 1st way the buffer was always in the end, because it already have loaded all the file!my $file = $0 ; open(FH, $file) ; while ( my $line = <FH> ) { my $tel = tell(FH) ; print "$tel>> $line" ; } close FH;
Graciliano M. P.
"The creativity is the expression of the liberty".
|
|---|