For example, require is executed at run-time, first compiling the referenced code, then running it immediately after (because it is essentially a super-eval, which compiles and runs code at runtime). BEGIN-blocks move the enclosed code from runtime to compiletime. Since "use" is a combination of BEGIN and require, it causes an external file to be compiled, then executed, during the compilation of the current file.
Also, variables are declared at compile time, subroutines are defined at compile time, but the initialization of variables doesn't happen until runtime.
Using basic rules like this, and paying attention to the other notes (like how //o and eval work, for example), it's always possible to work out the execution order "from first principles".
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to •Re^5: What can we assume in a BEGIN block ?
by merlyn
in thread What can we assume in a BEGIN block ?
by leriksen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |