JupiterHost.Net wrote:Thanmks for the info, I am actually fiddlin geith that as we speak... I used $class->export_to_level to do that in this particular module's import funtion. So far I have it getting the Module useable (Pun not intended ;p) So I can go, fro example $mod->import; Where $mod is CGI and be able to do CGI::header() from main:: but I stil cn't get the Export sysmbols to budge...
WC -Sx- Jones wrote:
JupiterHost.Net wrote:
Will work whether I do the require or use way....
require doesn't let you specify what to EXPORT though which is one of the goals of this funtion...
use does import the module's name *and* does the EXPORT symbols also *if* its called inside package Foo;
Do you *have* to export them?
That's part of the convenience :)
Using referneces didn't work and neither did fully naming them with the caller's package....
perl -mstrict -we 'use Foo qw(mod);if(mod("CGI","header")) { print header(); }'
does not and that is what I need it to do...
perl -mstrict -we 'use CGI qw(mod);\ if(mod("CGI","$CGI::header")) { print $CGI::header(); }'
Name your spaces fully. Yes, it gives a new error, but I'm not a Perl one-liner person...
I can do mod("CGI") and still do CGI::whatever i want so in that case I might as wlel just require()...
It seems like I need to fool use() into thinking it's being called by (caller())[0] (IE usually 'main' but not necessarily) instead of the actual package name mod() is exported from (unless its being calle d inside that package of course...
Thanks for the brain storming session :)
Lee.M - JupiterHost.Net
If I understand you correctly what you need to massage is 'import' rather than 'use'. 'use' just calls 'import' if available, and making a module an Exporter just provides a standard import, that doesn't mean you have to use it (pun intended).
In particular have a look at the section: "Exporting without using Exporter’s import method" in perldoc Exporter:
"Exporter has a special method, ’export_to_level’ which is used in situations where you can’t directly call Exporter’s import method. The export_to_level method looks like:
MyPackage->export_to_level($where_to_export, $package, @what_to_export);
where $where_to_export is an integer telling how far up the calling stack to export your symbols..."
Which sounds similar to what you are after. If it doesn't work a combination of caller and a home grown 'import' should get you there...
I'll read up on what you suggested and see how it goes,
Thanks again :)
Lee.M - JupiterHost.Net
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>