http://www.perlmonks.org?node_id=905635


in reply to Closure warning with Perl 5.14?

Remove the if after the declaration of $color. It serves no purpose and is leading to the error:
my $color = shift;
If you were ever to need initialize a variable conditionally, be sure to use the ternary operator
my $variable = $condition ? 'value' : undef;