logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Community::BarewordFilehandles - Don't use bareword filehandles other than

Affiliation

       This policy is part of Perl::Critic::Community.

Author

       Dan Book, "dbook@cpan.org"

Configuration

       This policy is not configurable except for the standard options.

Description

       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 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".

Name

       Perl::Critic::Policy::Community::BarewordFilehandles - Don't use bareword filehandles other than
       built-ins

See Also

       Perl::Critic, bareword::filehandles

perl v5.40.1                                       2025-03-22             Perl::Critic::P...wordFilehandles(3pm)

See Also