Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

BillKSmith's scratchpad

by BillKSmith (Monsignor)
on Mar 05, 2012 at 21:26 UTC ( #957974=scratchpad: print w/replies, xml ) Need Help??

Nataraj has posted the following update to One module to use them all (proxy moudle that exports subs of other modules).
Update: Partially solved here. This solution (Re: One module to use them all (proxy moudle that exports subs of other modules)) works for modules that uses Export for exporting. For other modules I added desired subs to export list explicitly. This did most of the trick.
From this I assume that most functions ‘work’ (i.e. The application tldr.pl can access them with unqualified names) . Later, he tells us that all the exceptions are in third party (‘not really mine’) modules which do not have use EXPORTER. It is reasonable to assume that these modules do not have an appropriate ‘import’ function. At least three solutions have been proposed. Any one of them would ‘work’ . None of them are exactly what the OP was hoping for.
  • Manually ‘import’ the function name(s) into the proxy module.
  • Edit the module to add use EXPORT
  • Edit the module to add a custom import function.

The second and third option are probably not available for third party modules. The first option has the advantage that all extra code is added to the ‘proxy’ module ‘ModAll’. This method fails to meet the OP's expectations only because the proxy module must be manually updated every time the library of third party functions is reorganized.

Demo of ‘manual’ method

Modification of Re: One module to use them all (proxy moudle that exports subs of other modules)

The following files are unchanged

  • tldr.pl
  • Mod1.pm
  • Mod2.pm

EXPORTER has been removed from Mod3.pm to simulate a 'third party' module.

package Mod3; use warnings; use strict; #use Exporter 'import'; #our @EXPORT = qw( m3 ); sub m3 { 'm3' } __PACKAGE__

Manual ‘import’ added to ModAll.pm

package ModAll; use warnings; use strict; use Mod1; use Mod2; use Mod3; use Exporter 'import'; # Supply function name ‘m3’ manually (not in any EXPORT list) #our @EXPORT = (@Mod1::EXPORT, @Mod2::EXPORT, @Mod3::EXPORT); our @EXPORT = (@Mod1::EXPORT, @Mod2::EXPORT, ‘m3’); *m3 = \&Mod3::m3 # hand code result of missing import; __PACKAGE__
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? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2023-10-04 09:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?