in reply to Which phase am I in?

What about setting a ref variable to point at the appropriate list in BEGIN, and then change it to point at the other list in INIT? Then, write all your code to use the ref variable.

Just a thought,
-v
"Perl. There is no substitute."

Replies are listed 'Best First'.
Re^2: Which phase am I in?
by Fletch (Bishop) on Nov 19, 2004 at 14:53 UTC

    Or do something along the lines of this near the beginning of your code:

    BEGIN { $__KLUDGE::phase = 'BEGIN'; } INIT { $__KLUDGE::phase = 'INIT'; } CHECK { $__KLUDGE::phase = 'CHECK'; } END { $__KLUDGE::phase = 'END'; }

    And then check $__KLUDGE::phase as necessary.

      The END (and the CHECK?) would have to be at the end of the code, not the beginning. Maybe they should be in an eval "" at the end of your script, because they're done Last Encountered, First Executed order.
        Um, no. Just like the BEGIN blocks do not have to be at the beginning of the code (but you might have to pay attention to scoping).

        Each END block, however, will be executed in LEFE order as you describe.

        Matt