#main script if($module) { use mod1; } else { use mod2; } test(); #mod1.pm sub test { print "Test"; } #mod2.pm sub test { print "Test1"; }