Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations3pm
Do not write " my $foo = $bar if $baz; ".
Affiliation
This Policy is part of the core Perl::Critic distribution.
Overview
Declaring a variable with a postfix conditional is really confusing. If the conditional is false, its not clear if the variable will be false, undefined, undeclared, or what. It's much more straightforward to make variable declarations separately.
my $foo = $baz if $bar; #not okmy $foo = $baz unless $bar; #not okour $foo = $baz for @list; #not oklocal $foo = $baz foreach @list; #not ok
Configuration
This Policy is not configurable except for the standard options.
Releases
10 releases since Debian 5.0 (Lenny); the text changed 9 times.