Perl::...gnAref(3pm)
π Perl::Critic::Policy::Community::ArrayAssignAref π
okay bestie, so this page is from the User Contributed Perl Documentation section, and the module we're talking about is Perl::Critic::Policy::Community::ArrayAssignAref β say that five times fast, I dare you π«Ά
β¨ NAME β¨
Perl::Critic::Policy::Community::ArrayAssignAref β pls stop assigning an anonymous arrayref to an array, it's giving chaos π
πΈ DESCRIPTION πΈ
so the tea is: a super common oopsie is wanting to put values into an array, but accidentally using arrayref brackets [] instead of parentheses (). and the result? your array ends up holding exactly one element β an arrayref β which is almost never what you actually meant. lowkey tragic π
but if that is what you meant (valid, icon behaviour), you can just wrap the arrayref brackets in parentheses for clarity. problem solved, no cap β¨
@array = []; # not ok
@array = [1, 2, 3]; # not ok
@array = ([1, 2, 3]); # ok
now for the lore π β this policy is a subclass of Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref, which is itself a fork of the Perl::Critic::Pulp policy Perl::Critic::Policy::ValuesAndExpressions::ProhibitArrayAssignAref. it does the exact same thing, but it's serving it in the "community" theme. same energy, different fit π
π¦ AFFILIATION π¦
this policy is part of Perl::Critic::Community. it's in the group chat, fr fr π
π CONFIGURATION π
not configurable, bestie. it's not like that. the only options you get are the standard options β that's it, that's the whole menu π
π AUTHOR π
Dan Book, dbook@cpan.org β the icon who wrote this π
π COPYRIGHT AND LICENSE π
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.
π SEE ALSO π
Perl::CriticPerl::Critic::Pulp
ngl this one's short but it's a life saver β go fix your array assignments, main character π
so yeah, that's the whole page! perl v5.40.1, dated 2025-03-22 β mwah, love u, go slay some lints π§β¨
π¦ where this page comes from
- debian trixie: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu resolute: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu stonking: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms