http://www.perlmonks.org?node_id=1045892


in reply to disambiguating require (or: require loves join more than catfile)

Are you ~sure~ this does what you want it to? Require behaves differently if you feed it a bareword or a variable. (Maybe this was the reason for catfile?)

http://perldoc.perl.org/functions/require.html

use strict; use warnings; my $x="x"; my $module = $x . '::' . $x; print "$module\n"; eval { require $module; };
The eval block needs some finetuning to actually do what you want it to. (Do something if require succeeds, do something else if require fails. Recommendation: Use Try::Tiny and stop worrying about all the ways eval / $! / $_ can go wrong.
use strict; use warnings; use Try::Tiny; my $x="x"; my $module = $x . '::' . $x; try { require $module; print "Found module $module.\n"; } catch { print "Failed to find module $module!\n"; };