extract_modules - determine which Perl modules a given file uses
Given Perl files, extract and report the Perl modules included with use or require.
use
require
# print a verbose text listing $ extract_modules filename [...] Modules required by examples/extract_modules: - Getopt::Std (first released with Perl 5) - Module::CoreList (first released with Perl 5.008009) - Pod::Usage (first released with Perl 5.006) - strict (first released with Perl 5) - warnings (first released with Perl 5.006) 5 module(s) in core, 0 external module(s) # print a succint list, one module per line $ extract_modules -l filename [...] Getopt::Std Module::CoreList Pod::Usage open strict warnings # print a succinct list, modules separated by null bytes # you might like this with xargs -0 $ extract_modules -0 filename [...] Getopt::StdModule::CoreListPod::Usageopenstrictwarnings # print the modules list as JSON $ extract_modules -j filename [...] [ "Getopt::Std", "Module::CoreList", "Pod::Usage", "open", "strict", "warnings" ]
This script does not execute the code in the files it examines. It uses the Module::Extract::Use or Module::ExtractUse modules which statically analyze the source without compiling or running it. These modules cannot discover modules loaded dynamically through a string eval.
Module::Extract::Use
Module::ExtractUse
Jonathan Yu <frequency@cpan.org>
<frequency@cpan.org>
brian d foy <bdfoy@cpan.org>
<bdfoy@cpan.org>
Copyright © 2009-2017, brian d foy <bdfoy@cpan.org>. All rights reserved.
You can use this script under the same terms as Perl itself.
Module::Extract::Use, Module::ExtractUse, Module::ScanDeps,
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '©'. Assuming UTF-8
To install Module::Extract::Use, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Extract::Use
CPAN shell
perl -MCPAN -e shell install Module::Extract::Use
For more information on module installation, please visit the detailed CPAN module installation guide.