Perl::Critic::Policy::Bangs::ProhibitNumberedNames - Prohibit variables and subroutines with names that end in digits.
This Policy is part of the Perl::Critic::Bangs distribution.
Similar variables should be meaningfully different. A lazy way to differentiate similar variables is by tacking a number at the end.
my $total = $price * $quantity; my $total2 = $total + ($total * $taxrate); my $total3 = $total2 + $shipping;
The difference between
$total3 is not described by the silly "3" at the end. Instead, it should be:
my $merch_total = $price * $quantity; my $subtotal = $merch_total + ($merch_total * $taxrate); my $grand_total = $subtotal + $shipping;
Both variable and subroutine names are checked.
See http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html for more of my ranting on this.
This policy has two options:
This policy starts with a list of numbered names that are legitimate to have ending with a number:
base64 md5 rc4 sha0 sha1 sha256 utf8 x11 win32
The exceptions for the policy also apply to names based on the exceptions. If
$base64 is acceptable as an exception, so is
$calculated_base64. The exception must be separated from the left part of the name by at least one underscore to be recognized.
The exceptions are case-insensitive.
$utf8 are both seen the same as far as being exceptions.
To replace the list of exceptions, specify a value for the
[Bangs::ProhibitNumberedNames] exceptions = logan7 babylon5
To add exceptions to the list, give a value for
add_exceptions in your .perlcriticrc file like this:
[Bangs::ProhibitNumberedNames] add_exceptions = adam12 route66
<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.