Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: What is Exported from modules

by gam3 (Curate)
on Jul 12, 2005 at 16:21 UTC ( #474318=note: print w/replies, xml ) Need Help??

in reply to What is Exported from modules

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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-01-27 06:33 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (70 votes). Check out past polls.