How can I determine if the modules used are pure perl?

If I have Perl code that use contains many modules, is there a quick and easy way to find out if some of these modules are pure Perl modules?

+7
source share
3 answers

@DynaLoader::dl_modules contains a list of loaded XS modules.

 perl -MSome::Module1 -MSome::Module2 -M... \ -MDynaLoader -E'say for sort @DynaLoader::dl_modules;' 

Or if you want to write it as a script:

 # Usage: script Some::Module1 Some::Module2 ... use 5.010; use DynaLoader qw( ); while (defined($_ = shift(@ARGV))) { s{::}{/}g; $_ .= ".pm"; require $_; } say for sort @DynaLoader::dl_modules; 

Of course, nothing prevents you from putting it in an existing script.

 use 5.010; use DynaLoader qw( ); END { say for sort @DynaLoader::dl_modules; } 
+7
source

It looks like work for what I call a "bloat sensor." You could just pick up the hooks by putting this at the top of the first module:

 BEGIN { require Carp; #Does the stack stuff # Fool Perl into thinking that these are already loaded. @INC{ 'XSLoader.pm', 'DynaLoader.pm' } = ( 1, 1 ); # overload boobytrapped stubs sub XSLoader::load { Carp::confess( 'NOT Pure Perl!' ); } sub DynaLoader::bootstrap { Carp::confess( 'NOT Pure Perl!' ); } } 
+7
source

If you need to try, which modules in your Perl program are not already installed on your computer. You can do it as follows:

 use ExtUtils::Installed; my $installed = ExtUtils::Installed->new(); my @miss; foreach $module ($installed->modules()){ @miss = $installed->validate($module); } print join("\n", @miss); 
-4
source

All Articles