Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Module/export problems

by jbeninger (Monk)
on Jun 18, 2003 at 04:18 UTC ( #266724=perlquestion: print w/ replies, xml ) Need Help??
jbeninger has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks. I'm having trouble exporting symbols to one module, but not another, and was hoping that in your infinite wisdom, you could guide me. In module Mod, I've got this:
package Mod; require Exporter; BEGIN { use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); %EXPORT_TAGS = (all => [qw(Foo Bar)]); @ISA = qw(Exporter); Exporter::export_ok_tags('all'); }
Then in App - the main application:
use Mod qw(:all); Foo()
And finally, in package Mod::Sub
package Mod::Sub use Mod qw(:all); Foo()
The final example (Mod::Sub) doesn't work - (Undefined subroutine &Mod::Sub::Foo...) Is there some problem stemming from including "parent" modules, or is this some unrelated problem?

Thanks in advance,
James

Comment on Module/export problems
Select or Download Code
Re: Module/export problems
by PodMaster (Abbot) on Jun 18, 2003 at 05:07 UTC
    You're missing a ';' in the final example. In the above code you've shown, there is no sub Foo defined in package Mod;
    package Mod; require Exporter; BEGIN { use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); %EXPORT_TAGS = (all => [qw(Foo Bar)]); @ISA = qw(Exporter); Exporter::export_ok_tags('all'); } sub Foo { die "I AM THE FOOO!!!" } package sorkeyso; BEGIN{ $INC{'Mod.pm'}=1} use Mod ':all'; Foo(); __END__ I AM THE FOOO!!! at - line 11.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Apologies - the semicolon and Foo() are both there in the actual code. The interesting part is that it succeeds when used by my other modules, just not in Mod::Sub, Mod::Sub2, etc. Is there any reason they wouldn't import like anything else, or should I be looking elsewhere?
        Do you get any errors? Are you useing the Mod.pm you think you are(check %INC)? Most likely you're not using the Mod.pm you think you are -- you didn't edit your Exporter.pm by any chance (you should check you're using the correct one as well)? There is nowhere else to look (unless you also use Mod::Blablah; which for some bizzare reason clobbers the %Mod::EXPORT_TAGS and other vars special to Exporter.pm -- bad).

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://266724]
Approved by antirice
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-11-29 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls