rrwo has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to know how in a module to tell if a function foo has been exported (when it isn't exported by default). That is,
use ThisModule qw(foo);
How in ThisModule can I tell that foo is being exported.
The real reason is that foo requires a bit of initialization, and I don't want to do this unless necessary.
I could do something like:
{ my $value = undef; sub foo { unless (defined $value) { # initialize $value here } # do foo stuff using $value here } }
I believe this isn't Apache mod_perl-friendly. (Or am I wrong?)
Suggestions to answer both problems (how to tell if a function is exported from within a module, and the best way to initialize a variable the first time a function is called) would be helpful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to tell if a sub has been exported?
by suaveant (Parson) on Oct 05, 2001 at 07:28 UTC | |
|
Re (tilly) 1: How to tell if a sub has been exported?
by tilly (Archbishop) on Oct 05, 2001 at 07:31 UTC | |
|
Re: How to tell if a sub has been exported?
by miyagawa (Chaplain) on Oct 05, 2001 at 06:18 UTC | |
by rrwo (Friar) on Oct 06, 2001 at 08:26 UTC | |
by miyagawa (Chaplain) on Oct 06, 2001 at 12:04 UTC | |
|
Re: How to tell if a sub has been exported?
by perrin (Chancellor) on Oct 05, 2001 at 08:15 UTC |