Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 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


EXPORTER has been removed from 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

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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2023-12-04 09:45 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (23 votes). Check out past polls.