Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't think you can get all the imports from inside the module becuase you would not be sure what had been imported from the EXPORT_OK array. But by looking at @_module_::EXPORT and @_module_::EXPORT_OK you should be able to get a good idea of what was imported. The problem would be if you have 2 modules that export the name in the EXPORT_OK array.

Update: Added example code.

use one qw (one two three five); use two qw (one two four); print join("\n", @one::EXPORT), "\n"; sub get_exports { my $package = shift or die; my @list = (@{$package . "::EXPORT"}, @{$package . "::EXPORT_OK"} +); for my $name (@list) { my $symbol = $package . '::' . $name, " ", "\n"; if (\&{$symbol} == \&{$name}) { print "$name is imported from $package (function)\n"; } } } get_exports('one'); print "\n"; get_exports('two') print"\n"; print join(' ', one, two, three, four), "\n";
package one; use base Exporter; our @EXPORT = qw (one two); our @EXPORT_OK = qw (three four five); sub one { 1.1; } sub two { 1.2; } sub three { 1.3; } sub four { 1.4; } sub five { 1.5; }
package two; use base Exporter; our @EXPORT = qw (one two); our @EXPORT_OK = qw (three four); sub one { 2.1; } sub two { 2.2; } sub three { 2.3; } sub four { 2.4; }
-- gam3
A picture is worth a thousand words, but takes 200K.

In reply to Re: What is Exported from modules by gam3
in thread What is Exported from modules by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found