Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^4: Use of uninitialised value... but it is defined ?!by Discipulus (Canon) |
on Mar 02, 2016 at 08:33 UTC ( [id://1156627]=note: print w/replies, xml ) | Need Help?? |
BrowserUk: exactly, the order matter. the slot for the variable is created (no errors for undeclared variables) but the assignement not yet.
BEGIN blocks jump directly in runtime during the compilation of the program. Quite a good feature! Consider the output of the following snippet: perl -wE "my $time = time; BEGIN{say time; sleep 5}; say $time" PS the above behaves the same with lexical and package vars: perl -E "$time = time; BEGIN{say time; sleep 5}; say $time" L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|