Why am I getting a closed filehandle error when using the diamond operator in list context in Perl?
- by gvkv
This code:
foreach my $file (@data_files) {
open my $fh, ',', $file || croak "Could not open file $file!\n";
my @records = <$fh>;
close $fh;
....
}
produces this error:
readline() on closed filehandle $fh at nut_init_insert.pl line 29.
and I have no idea why.