Perl::Critic::Policy::Community::BarewordFilehandles(3pm)

Perl::Critic::Policy::Community::BarewordFilehandles3pm

Don't use bareword filehandles other than built-ins

Overview

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

Affiliation

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

Configuration

This policy is not configurable except for the standard options.

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Author

Dan Book, "[email protected]"

From libperl-critic-community-perl 1.0.4-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.