It can easily be done. I posted in the above node some example code on how to do it, but unfortunately the solution contained a typo, and the node was clouded over by critism from those who couldn't look past that. The example should work fine now; please give it a try.
| [reply] |
Hi jryan,
What about doing this?:
package whatever;
require Exporter;
use anything;
push(@EXPORT, @anything::EXPORT);
I got this snippet from the source of LWP::Simple. I am not sure what is going on, but it worked. But I can't export strict for some reason. I could export other modules like diagnostics. What is going on here? And is your way better? Thanks. | [reply] [d/l] |
I think you are seeing different behaivor than you think you are. The above code looks like it might be used to, for lack of a better term, "functionally subclass" a module. By that, I mean that the "subclass" exports everything that the "base class" does, in addition to its own exports. For instance, in the LWP::Simple module, the "use anything;" in question happens to be "use Http::Status". Http::Status happens to have a huge list of default Exports, so the author uses the above code in order to save his code from repetition. (which is A Bad Thing)
As for the behaivor that you think you are seeing, the problem is that diagnostics isn't lexical like strict is. It operates as a global switch; either diagnostics is on or it isn't. (You can use the kludgy enable and disable to acheive lexical behaivor). However, strict is lexical, which is why nothing happend. (Besides, diagnostics mostly operates at runtime, and strict 'vars' operates at compile time. By the time the above code is run, it is already runtime, and so it would be tough for strict 'vars' to have an effect (-: )
So, in short; yes, my solution is "way better." (-:
| [reply] [d/l] [select] |