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

seki has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I got the "Use of uninitialised value" warning but the variable looks like being defined to me, so it must be a perlism that I am missing...
Maybe It is related to the closure mechanism, but in that case I do not get the point...
>perl -w test_mod.pl
Use of uninitialized value $variable in concatenation (.) or string at test_mod.pl line 12.
Use of uninitialized value $variable in say at test_mod.pl line 15. Foo::begin
test_mod.pl
use strict; use warnings; use feature 'say'; Foo->test(); { package Foo; my $variable = "bar"; BEGIN { say __PACKAGE__."::begin $variable"; } sub test { say $variable; } }
The best programs are the ones written when the programmer is supposed to be working on something else. - Melinda Varian