Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Understanding module structure and inheritance

by bradcathey (Prior)
on Jan 30, 2008 at 15:30 UTC ( #665147=note: print w/ replies, xml ) Need Help??


in reply to Re: Understanding module structure and inheritance
in thread Understanding module structure and inheritance

Great, that helps. Is there any other way to include Common.pm in Main.pm that would include the symbol for Common::show_here?

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot


Comment on Re^2: Understanding module structure and inheritance
Re^3: Understanding module structure and inheritance
by jaldhar (Vicar) on Jan 30, 2008 at 15:42 UTC

    Well, seeing as you are using CGI::Application, see the docs about making a plugin. Most of the existing plugins are just simple wrappers around CPAN modules so you can use them as examples.

    --
    જલધર

Re^3: Understanding module structure and inheritance
by naikonta (Curate) on Jan 30, 2008 at 18:35 UTC
    Hi, bradcathey,
    $ cat Common.pm package Common; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); # borrows import() our @EXPORT = qw(show_here); sub show_here { } 1; $ cat Main.pm package Common; use strict; use warnings; use Common; sub show_me {} 1;
    The caller of Main.pm has direct access to show_me() and show_here() using qualified name,
    Main::show_here; # since exported by default by Common.pm Main::show_me; # originally in Main.pm
    If the caller has its own use Common then it doesn't have to qualify it, show_here() is enough.

    However, if you meant that "a way to include Common.pm in Main.pm so Contact.pm can use show_here directly, then make Main.pm to reexport the function.

    package Main; .... use Exporter; use Common; our @ISA = qw(Exporter); # borrows import() our @EXPORT = qw(show_here); # just @Common::Export to export # what ever Common exports. .... sub show_me {} 1;
    The caller,
    use Main; Main::show_me(); show_here()

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-12-21 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls