in reply to How to dynamically load modules

Just require the modules and don't import the functions that have the same name; invoke them using their fully qualified names. E.g. if both Module1 and Module2 have foo:

require Module1; require Module2; Module1::foo(); Module2::foo();
With eval, the above translates to:
my $mod = some_condition() ? 'Module1' : 'Module2'; eval "require $mod; ${mod}::foo()";

TIMTOWTDI: I find the problem description admits too many different interpretations, leading to entirely different solutions; anyway, here's another possible form the solution could take:

use strict; use warnings; my $mod = shift; require "$mod.pm"; eval "$mod->import(); 1" or die; # modules all export 'foo' by defaul +t # eval "$mod->import( 'foo' ); 1" or die; foo();
Use the commented-out eval instead if you want to limit the functions that are imported.

the lowliest monk