in reply to Re: BEGIN vs initialization
in thread BEGIN vs initialization
Step 2.2 (execute Gbl) takes place before returning to parse more of the main.pl! Therefore the variables will hold valid definitions when main's BEGIN block used them.
I was picturing that in the absence of BEGIN and CHECK sort of diversions, that the entire file structure (including all the 'use' modules) would be assembled/parsed, then executed starting back at the top. That is a holdover from the old 'C'/cpp days.
That also explains why BEGIN blocks execute during a "perl -c main.pl" syntax checking run.
Thanks for a the concise answer to my fundamental question..
It is always better to have seen your target for yourself, rather than depend upon someone else's description.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: BEGIN vs initialization
by ikegami (Patriarch) on Dec 01, 2009 at 07:46 UTC |