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

POC/RFC: Changes to Exporter;

by clueless newbie (Hermit)
on Dec 28, 2010 at 21:03 UTC ( #879511=perlquestion: print w/ replies, xml ) Need Help??
clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:

Our shop has a lot of legacy code that uses Exporter and relies more on @EXPORT than @EXPORT_OK. So a program that uses a few inhouse modules may well have had a noiseless name space collision ie (more than one module exports the same name). Since I was a nice boy, Santa brought me something to play with - Exporter. Tinkering resulted in a modified Exporter.pm and Exporter::Heavy.pm. In Exporter::Heavy the modified sub heavy_export preserves $callpkg, $pkg and $sym in the hash ref $Exporter::Exported. In Exporter a new INIT block checks the symbols in each in-house script/module to see if they were "exported" more than once before terminating. Putting Exporter.pm and Exporter::Heavy.pm into a local library allowed me do "perl -I<locallib> <script/module>" ie use this modified exporter.
C:\Exporter>perl -I. test_03.pl Subroutine jkl redefined at test_03.pl line 16. Begin Exporter::CHECK main::abc local <*> One::abc main::def One::def <*> Two::def main::ghi Two::ghi <*> Three::ghi main::jkl Three::jkl <*> local End Exporter::CHECK Exports list has been generated. Exporter will now terminate.
which claims that "main" defined a sub "abc" which was replaced by the "abc" exported by "One". The "def" exported by "One" was replaced by the "def" exported by "Two", etc. (Far more things are exported but we're only interested in the potential collisions.) Would these changes be considered useful enhancements or ?

Comment on POC/RFC: Changes to Exporter;
Download Code
Re: POC/RFC: Changes to Exporter;
by JavaFan (Canon) on Dec 28, 2010 at 21:14 UTC
    Warnings already tells me if I'm importing the same subroutine more than once (and if I were to import explicitly (which I can do regardless whether the exporting module uses @EXPORT or @EXPORT_OK) a visual inspection tells me as well), so I would not consider this a useful enhancement.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://879511]
Approved by BrowserUk
Front-paged by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-12-27 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (177 votes), past polls