Perl::C...edNames(3)

πŸ“¦
version 1.14 Β· 2 versions
, in fedora 43

πŸ’– Perl::Critic::Policy::Bangs::ProhibitNumberedNames(3) πŸ’–

okay bestie, pull up a chair, this one's from the User Contributed Perl Documentation section of the manual (the header's so long it literally got truncated to Perl::C...edNames(3), rip 😭). it's a Perl::Critic policy and it's about to gently bully your variable names. affectionately. 🫢


✨ NAME ✨

Perl::Critic::Policy::Bangs::ProhibitNumberedNames β€” no variables and no subroutines with names that end in digits. that's it. that's the whole gig. πŸ’…


πŸŽ€ AFFILIATION πŸŽ€

this Policy is part of the Perl::Critic::Bangs distribution. so it rolls with the Bangs crew. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: similar variables should be meaningfully different, bestie. and the lazy girl way to differentiate similar variables is to just tack a number on the end. it's giving "i ran out of ideas" energy. πŸ™ˆ

like, look at this:

my $total = $price * $quantity;
my $total2 = $total + ($total * $taxrate);
my $total3 = $total2 + $shipping;

the difference between $total and $total3 is not described by that silly little "3" you stapled on the end. the 3 is not lore. the 3 explains nothing. it's just a number hanging out. πŸ’€

instead, it should be:

my $merch_total = $price * $quantity;
my $subtotal = $merch_total + ($merch_total * $taxrate);
my $grand_total = $subtotal + $shipping;

see? now every name actually tells you something. main character naming. 🌟

and heads up β€” both variable names AND subroutine names get checked. nobody escapes the vibe check. πŸ•΅οΈβ€β™€οΈ

if you want more of the author's ranting on this exact topic, it lives at:

http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html


🌸 CONFIGURATION 🌸

this policy has two options: "exceptions" and "add_exceptions". two little knobs. very manageable. πŸ’–

πŸ’œ "exceptions" πŸ’œ

so this policy starts with a built-in list of numbered names that are genuinely, legitimately allowed to end in a number:

base64 md5 rc4 sha0 sha1 sha256 utf8 x11 win32

because base64 is not a lazily-numbered variable, it's just... a word. respect. ✨

and here's the tea: the exceptions also apply to names based on the exceptions. if $base64 is acceptable as an exception, then $calculated_base64 is too. slay. πŸŽ€

but β€” and this is the important bit β€” the exception must be separated from the left part of the name by at least one underscore for it to be recognized. no underscore, no exception. iykyk.

also, the exceptions are case-insensitive. $UTF8 and $utf8 are both seen the same as far as being exceptions. equal treatment. we love to see it. πŸ’…

if you want to replace the whole list of exceptions instead of adding to it, you just specify a value for the "exceptions" option, like:

[Bangs::ProhibitNumberedNames]
exceptions = logan7 babylon5

iconic taste btw. 🌈

πŸ’– "add_exceptions" πŸ’–

orrrr if you just want to add to the list (don't erase the defaults, bestie, they're trying their best), give a value for "add_exceptions" in your .perlcriticrc file, like this:

[Bangs::ProhibitNumberedNames]
add_exceptions = adam12 route66

boom. added. periodt. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Andy Lester "<andy at petdance.com>"


Copyright (c) 2006-2013 Andy Lester

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.


and that's the whole page, bestie!! πŸŽ‰ this was perl v5.42.0, dated 2025-07-25, served up as Perl::C...edNames(3) β€” yes the header is still truncated, no i will not be fixing it, it's part of the charm now. πŸ’€πŸ’– go rename your $total2 to something with meaning. mwah. πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from