I have to read a big (BIG) file in memory, line by line, using perl.
In case of some error, function open() does return false and $! is set to the system error.
But, if I get some errors reading the file?
I use this code:
open(STATISTICS, "<" . $statisticsFile) or die "Can't open statistics file $statisticsFile ($!)";
while (<STATISTICS>) {
my $line = $_;
...
}
close($STATISTICS);
Any hint?
You can change your code to work as shown below.
You seem to be using both
STATISTICSand$STATISTICSfor your file handle. Since lexical handles are prefereable I have used$stathere.