And in FOO.pmuse FOO qw(bar); bar();
Exporter gives you the export_to_level method to allow you to override import like this. Now you can examine the list import is called with at compile time and set things up accoringly.package FOO; use base Exporter; our @EXPORT_OK = qw(bar); sub import { print "Exporting the following from @_\n"; FOO->export_to_level(1, @_); } sub bar { print "Hello world\n"; } 1;
Realize, of course, that bar can be called without being exported, using FOO::bar()... you probably should do something along the lines of initializing if it is exported, and initializing it on the first call if it is called without being initialized properly. You can do tricks with AUTOLOAD and the like that can be fun :)
- Ant
- Some of my best work - Fish Dinner
In reply to Re: How to tell if a sub has been exported?
by suaveant
in thread How to tell if a sub has been exported?
by rrwo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |