in reply to Avoiding variable conflict when importing modules
With all of the bells and whistles in Exporter.pm, it is almost a shame that no provisions were made for renaming on import:
(no, this doesn't work)use ModuleA qw( function ); use ModuleB qw( operate=function ); function(); # calls ModuleA::function() operate(); # calls ModuleB::function()
But you can roll your own rather easily, for example:
There are certainly other ways to do it but I chose this way because it works with bizarre modules like CGI.pm and shouldn't trigger Exporter.pm's warning about exporting functions over the top of each other (if it has or will one day have such a warning). One disadvantage of this method is that you have to be careful of the order in which you use your modules. - tye (but my friends call me "Tye")use ModuleB qw( function ); BEGIN { *operate= \&function; undef \&function } use ModuleA qw( function );
|
|---|