dgaramond2 has asked for the wisdom of the Perl Monks concerning the following question:
I made a poor judgement in one of my modules and mixed in some code (say A+B) in a sub (say foo()). foo() is called from other modules (outside of any sub, so they run in BEGIN phase) as well as in the main script (so they run in run-time phase).
Turns out, the A portions of the code actually should not really be run until run-time phase. But foo() is called in many places so, pending refactoring, I want to do a quick-fix first and tackle A & B.
Now I need to be able to check whether I am running in BEGIN phase or not, to prevent A from being run in BEGIN phase (when called by other modules), but I want to let A run when in run-time phase. Is there a way to do that? I only see something like $^C in perlvar.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I know if I'm in a BEGIN block?
by kyle (Abbot) on Oct 29, 2009 at 03:35 UTC | |
by dgaramond2 (Monk) on Oct 29, 2009 at 13:59 UTC | |
Re: How do I know if I'm in a BEGIN block?
by dave_the_m (Monsignor) on Oct 29, 2009 at 10:54 UTC | |
Re: How do I know if I'm in a BEGIN block?
by LanX (Saint) on Oct 30, 2009 at 02:31 UTC | |
Re: How do I know if I'm in a BEGIN block?
by Kirsle (Pilgrim) on Oct 29, 2009 at 21:23 UTC |