Perl::...yCommas(3pm)
π NAME π
Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyCommas β bestie, this policy says no to empty consecutive commas, okay? Periodt.
β¨ DESCRIPTION β¨
So this policy lives inside the Perl::Critic::Pulp add-on π. What it does is it prohibits the empty comma operators , or =>, which basically means either commas that are back-to-back with nothing between them, or a comma chillin' at the very start of a list or an expression. It's giving "who left this here" π.
print 'foo',,'bar'; # bad
@a = (,1,2); # bad
foo (x, => 123); # bad
a =>=> 456; # bad
for (; $i++<10; $i++,,) # bad
func (,) # bad
And likeβ¦ the tea is that extra commas like this are harmless π₯ β they literally just collapse out the second the program runs (see List value constructors in perldata). So this policy is only under the cosmetic theme (see POLICY THEMES in Perl::Critic). Usually this kind of thing is just a stray, or leftover from a cut and paste moment, or maybe someone got a lil too enthusiastic with their column layout, iykyk.
But occasionally it can be something more dubious π:
# did you mean 1..6 range operator?
@a = (1,,6); # bad
# this is two args, did you want three?
foo (1, , 2); # bad
# this is three args, probably you forgot a value
bar (abc => , # bad
def => 20);
Now a comma at the end of a list or call? That's allowed, bestie, we're not monsters π«Ά. That's super normal and honestly it's a good thing when you're cutting and pasting lines around (see RequireTrailingCommas to mandate them!).
@b = ("foo",
"bar", # ok
);
And if you use multiple commas in some systematic way for your code layout, no stress π
β you can always disable ProhibitEmptyCommas from your .perlcriticrc file in the usual way (see CONFIGURATION in Perl::Critic):
[-ValuesAndExpressions::ProhibitEmptyCommas]
π SEE ALSO π
Perl::Critic::PulpPerl::CriticPerl::Critic::Policy::CodeLayout::RequireTrailingCommasPerl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatementsPerl::Critic::Policy::Tics::ProhibitManyArrows
π¦ HOME PAGE π¦
http://user42.tuxfamily.org/perl-critic-pulp/index.html
π COPYRIGHT π
Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
okay that's the whole page, no cap π and for the record this lil manual ships with perl v5.40.1, dated 2025-10-21 β mwah, iconic, love that for us πΈβ¨
π¦ where this page comes from
- ubuntu resolute: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- ubuntu stonking: libperl-critic-pulp-perl 100-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms