In some cases, you need to determine the absolute path name of the Perl module, but you do not need to load the Perl module:
use strict; use warnings; my $mod_name = 'My::Module'; my $abs_path = mod_name_to_abs_path( $mod_name ); sub mod_name_to_abs_path { my ( $mod_name ) = @_; my $rel_fn = $mod_name =~ s{::}{/}gr; $rel_fn .= '.pm'; require $rel_fn; return $INC{$rel_fn}; }
The above code loads the module (via require ).
How to determine the absolute name of a module path without using require?
source share