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

Perl::Critic::Policy::Community::ArrayAssignAref3pm

Don't assign an anonymous arrayref to an array

Overview

A common mistake is to assign values to an array but use arrayref brackets "[]" rather than parentheses "()". This results in the array containing one element, an arrayref, which is usually unintended. If intended, the arrayref brackets can be wrapped in parentheses for clarity.

 @array = [];          # not ok
 @array = [1, 2, 3];   # not ok
 @array = ([1, 2, 3]); # ok

This policy is a subclass of Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref, which is a fork of the Perl::Critic::Pulp policy Perl::Critic::Policy::ValuesAndExpressions::ProhibitArrayAssignAref, and performs the same function but in the "community" theme.

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.