in reply to Closure warning with Perl 5.14?
I don't get warnings from other closures.
It is because the declaration of $color is conditional.
my $color = shift if @_;
If you only pass 1 parameter to the outer sub, $color will never be declared, so won't (can't) be available to the inner sub.
If you just dropped the conditional, the code would work properly. If you shift a value from an empty array into a scalar it will be set to undef which will work fine in the inner sub conditional.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Closure warning with Perl 5.14?
by BerntB (Deacon) on May 19, 2011 at 08:45 UTC | |
by moritz (Cardinal) on May 19, 2011 at 10:24 UTC | |
by BerntB (Deacon) on May 19, 2011 at 11:11 UTC | |
by BrowserUk (Patriarch) on May 19, 2011 at 08:51 UTC | |
by BerntB (Deacon) on May 19, 2011 at 08:56 UTC | |
by BrowserUk (Patriarch) on May 19, 2011 at 09:03 UTC | |
by JavaFan (Canon) on May 19, 2011 at 09:11 UTC | |
by tye (Sage) on May 19, 2011 at 17:02 UTC | |
by BerntB (Deacon) on May 19, 2011 at 09:19 UTC | |
by JavaFan (Canon) on May 19, 2011 at 09:45 UTC | |
by ikegami (Patriarch) on May 19, 2011 at 09:55 UTC | |
| |
by John M. Dlugosz (Monsignor) on May 19, 2011 at 13:41 UTC | |
|