Hello,

I cannot understand, why perlcritic complains about this script:
use strict;
use warnings;
use 5.012;

open my $file, '<', 'file.txt';
my @array;

while (<$file>) {
    chomp;

    my $value = $_*2;
    say "OK";
    push @array, $value;
}
close $file;

$ perlcritic -4 t16.pl 
Close filehandles as soon as possible after opening them at line 25, 
column 1.  See page 209 of PBP.  (Severity: 4)

When I remove the "say" line, it says source OK. But anyway it is not
possible to close the file earlier (?)

Is it a bug in perlcritic?

Thank you

Lubos
PS. The script does not do anything terribly useful, I created it to 
demonstrate the perlcritic behaviour...


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to