in reply to Re: How not to hardcode a package name?
in thread How not to hardcode a package name?
package Array::Extract; our $worker_pkg; ... package Array::Extract::Worker; BEGIN { $Array::Extract::worker_pkg = __PACKAGE__ }
I didn't know I could do that. Or better: I hadn't thought I could do that. Of course the nice point is that in the BEGIN block I don't need to specify the full package name of $worker_pkg, since our creates an alias to it in all the lexical scope surrounding it.
Similarly, I may still be using a regular lexical variable. I'm wondering if there are any possible drawbacks/differences/gotchas with one approach wrt the other.
Update: I choose BEGIN out of habit, maybe something later like CHECK or INIT might be better, but then again they might cause problems with mod_perl.
I must admit I know next to nothing about those special blocks, and I should probably read up something. Re mod_perl, I'm not a web programmer, but it's good to know anyway. Although I can't understand why: if it's valid Perl, it should continue to work in that environment too...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How not to hardcode a package name?
by moritz (Cardinal) on Aug 28, 2008 at 10:57 UTC | |
by blazar (Canon) on Aug 28, 2008 at 12:32 UTC |