# Change the sprintf . . . $pkg = sprintf("%s/%s", $dir, $mod); # . . . OR change the require to be inside an eval eval "require $pkg";