my $moduleName = "Foo"; eval "use $moduleName"; if ($@) { # could be problems with the loading of the module Foo .... }