in reply to Use of uninitialised value... but it is defined ?!
BEGIN blocks run before the rest of the code in the module is even interpreted, so at the time when BEGIN { say __PACKAGE__."::begin $variable"; } runs, the lexical variable $variable has not been created, so the global variable of that name is used, and it has no value; hence the warning.
Solution: don't close over lexical variables in BEGIN blocks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use of uninitialised value... but it is defined ?!
by dave_the_m (Monsignor) on Mar 02, 2016 at 07:57 UTC | |
by BrowserUk (Patriarch) on Mar 02, 2016 at 08:09 UTC | |
by dave_the_m (Monsignor) on Mar 02, 2016 at 08:37 UTC | |
by BrowserUk (Patriarch) on Mar 02, 2016 at 09:31 UTC | |
by Eily (Monsignor) on Mar 02, 2016 at 08:28 UTC | |
by Discipulus (Canon) on Mar 02, 2016 at 08:33 UTC |