You can check this yourself with the following untested code:
Now you have the time for the 'while' loop with and without your 'do something' actual code.use strict; use warnings; use Time:HiRes qw( gettimeofday ); open ( my $fh, "<", "./something.txt" || die "! open $!\n"; my $stime = gettimeofday; while (<$fh>) { } print gettimeofday - $stime, "\n"; close $fh; open ( $fh, "<", ".something.txt" || die "! open $!\n"; $stime = gettimeofday; while (<$fh>) { # do something is your actual code! } print gettimeofday - $stime, "\n"; close $fh;
I suspect your experiential growth is something your doing in the 'do something' part of the script. Post it and we may help improve the process.
Regards...Ed
"Well done is better than well said." - Benjamin Franklin
In reply to Re: How does the while works in case of Filehandle when reading a gigantic file in Perl
by flexvault
in thread How does the while works in case of Filehandle when reading a gigantic file in Perl
by raj4489
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |