in reply to Which phase am I in?
Suppose that you have a module that I require from the body of my code. Then your BEGIN happens at the main run time of the program, and you never see CHECK or INIT. If you depended on initializations happening in CHECK or INIT, then they didn't. (Guess why I avoid attributes?) In fact if the require is triggered by a function call in an END block, then your BEGIN may be nested in an END. Going the other way if there is a compilation error, then even normal END blocks might be triggered while you are in compile phase.
If you're doing mod_perl development with Apache::Reload, then this matters a lot because you will be reloading stuff at runtime. Being able to work with this module can speed up your development cycle a lot.
So is BEGIN earlier or later than CHECK or INIT or END? It varies. Which ones are guaranteed to happen in your program? Assuming no errors, only BEGIN and END.
Therefore I consider CHECK and INIT, or anything that depends on stuff happening during CHECK and INIT, to be fragile and to be avoided. (Then again I'm an old curmudgeon...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Which phase am I in?
by dragonchild (Archbishop) on Nov 20, 2004 at 04:15 UTC | |
by tilly (Archbishop) on Nov 20, 2004 at 16:14 UTC | |
by dragonchild (Archbishop) on Nov 20, 2004 at 20:18 UTC | |
by BrowserUk (Patriarch) on Nov 20, 2004 at 09:08 UTC | |
by adamk (Chaplain) on Nov 20, 2004 at 20:36 UTC | |
by dragonchild (Archbishop) on Nov 20, 2004 at 20:40 UTC |