Perl::...gnAref(3pm)

πŸ“¦
version 1.0.4 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’… 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 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::Critic
  • Perl::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