Perl::Critic::Policy::Freenode::BarewordFilehandles - Don't use bareword filehandles other than built-ins
Bareword filehandles are allowed in open() as a legacy feature, but will use a global package variable. Instead, use a lexical variable with my so that the filehandle is scoped to the current block, and will be automatically closed when it goes out of scope. Built-in bareword filehandles like STDOUT and DATA are ok.
open()
my
STDOUT
DATA
open FH, '<', $filename; # not ok open my $fh, '<', $filename; # ok
This policy is similar to the core policy Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles, but allows more combinations of built-in bareword handles and filehandle-opening functions such as pipe and socketpair.
pipe
socketpair
This policy is part of Perl::Critic::Freenode.
This policy is not configurable except for the standard options.
Dan Book, dbook@cpan.org
dbook@cpan.org
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Perl::Critic, bareword::filehandles
To install Perl::Critic::Freenode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Freenode
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Freenode
For more information on module installation, please visit the detailed CPAN module installation guide.