Is there any way to find out which @INC path the module was loaded from?

Use case

My sysadmin has just installed the Perl module via rpm and although I can successfully use it in one layer, I want to know where the module was installed.

I can obviously comb each of the path locations in @INC , but is there any way for Perl to tell me where it successfully loaded the module from?

+5
source share
1 answer

What is the %INC . Hash for? It shows you where the module was loaded from.

 $ perl -MDBI -MData::Dumper -E'say Dumper \%INC' $VAR1 = { 'XSLoader.pm' => '/usr/share/perl5/XSLoader.pm', 'warnings/register.pm' => '/usr/share/perl5/warnings/register.pm', 'List/Util.pm' => '/usr/local/lib64/perl5/List/Util.pm', 'warnings.pm' => '/usr/share/perl5/warnings.pm', 'DBI.pm' => '/usr/lib64/perl5/vendor_perl/DBI.pm', 'overloading.pm' => '/usr/share/perl5/overloading.pm', 'Config.pm' => '/usr/lib64/perl5/Config.pm', 'Carp.pm' => '/usr/share/perl5/vendor_perl/Carp.pm', 'bytes.pm' => '/usr/share/perl5/bytes.pm', 'Exporter/Heavy.pm' => '/usr/share/perl5/vendor_perl/Exporter/Heavy.pm', 'Scalar/Util.pm' => '/usr/local/lib64/perl5/Scalar/Util.pm', 'strict.pm' => '/usr/share/perl5/strict.pm', 'Exporter.pm' => '/usr/share/perl5/vendor_perl/Exporter.pm', 'vars.pm' => '/usr/share/perl5/vars.pm', 'constant.pm' => '/usr/share/perl5/vendor_perl/constant.pm', 'overload.pm' => '/usr/share/perl5/overload.pm', 'DynaLoader.pm' => '/usr/lib64/perl5/DynaLoader.pm', 'Data/Dumper.pm' => '/usr/lib64/perl5/vendor_perl/Data/Dumper.pm', 'feature.pm' => '/usr/share/perl5/feature.pm' }; 

Update: Actually there is an easier way.

 $ perldoc -lm Your::Module 
+6
source

Source: https://habr.com/ru/post/1265730/


All Articles