Module::Extract::Use - Pull out the modules a module uses
use Module::Extract::Use; my $extor = Module::Extract::Use->new; my @modules = $extor->get_modules( $file ); if( $extor->error ) { ... } my @details = $extor->get_modules_with_details( $file ); foreach my $detail ( @details ) { printf "%s %s imports %s\n", $detail->module, $detail->version, join ' ', @{ $detail->imports } }
Extract the names of the modules used in a file using a static analysis. Since this module does not run code, it cannot find dynamic uses of modules, such as eval "require $class".
eval "require $class"
Makes an object. The object doesn't do anything just yet, but you need it to call the methods.
Set up the object. You shouldn't need to call this yourself.
Returns a list of namespaces explicity use-d in FILE. Returns undef if the file does not exist or if it can't parse the file.
Each used namespace is only in the list even if it is used multiple times in the file. The order of the list does not correspond to anything so don't use the order to infer anything.
Returns a list of hash references, one reference for each namespace explicitly use-d in FILE. Each reference has keys for:
namespace - the namespace, always defined version - defined if a module version was specified imports - an array reference to the import list
Return the error from the last call to get_modules.
get_modules
Make it recursive, so it scans the source for any module that it finds.
Module::ScanDeps
The source code is in Github: git://github.com/briandfoy/module-extract-use.git
brian d foy, <bdfoy@cpan.org>
<bdfoy@cpan.org>
Copyright (c) 2008-2011, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.
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.