1Module::Extract::Use(3)User Contributed Perl DocumentatioMnodule::Extract::Use(3)
2
3
4
6 Module::Extract::Use - Pull out the modules a module explicitly uses
7
9 use Module::Extract::Use;
10
11 my $extor = Module::Extract::Use->new;
12
13 my @modules = $extor->get_modules( $file );
14 if( $extor->error ) { ... }
15
16 my $details = $extor->get_modules_with_details( $file );
17 foreach my $detail ( @$details ) {
18 printf "%s %s imports %s\n",
19 $detail->module, $detail->version,
20 join ' ', @{ $detail->imports }
21 }
22
24 Extract the names of the modules used in a file using a static
25 analysis. Since this module does not run code, it cannot find dynamic
26 uses of modules, such as "eval "require $class"". It only reports
27 modules that the file loads directly. Modules loaded with "parent" or
28 "base", for instance, will will be in the import list for those pragmas
29 but won't have separate entries in the data this module returns.
30
31 new Makes an object. The object doesn't do anything just yet, but you
32 need it to call the methods.
33
34 init
35 Set up the object. You shouldn't need to call this yourself.
36
37 get_modules( FILE )
38 Returns a list of namespaces explicity use-d in FILE. Returns undef
39 if the file does not exist or if it can't parse the file.
40
41 Each used namespace is only in the list even if it is used multiple
42 times in the file. The order of the list does not correspond to
43 anything so don't use the order to infer anything.
44
45 get_modules_with_details( FILE )
46 Returns a list of hash references, one reference for each namespace
47 explicitly use-d in FILE. Each reference has keys for:
48
49 namespace - the namespace, always defined
50 version - defined if a module version was specified
51 imports - an array reference to the import list
52 pragma - true if the module thinks this namespace is a pragma
53
54 Each used namespace is only in the list even if it is used multiple
55 times in the file. The order of the list does not correspond to
56 anything so don't use the order to infer anything.
57
58 error
59 Return the error from the last call to "get_modules".
60
62 · Make it recursive, so it scans the source for any module that it
63 finds.
64
66 Module::ScanDeps
67
69 The source code is in Github:
70
71 git://github.com/briandfoy/module-extract-use.git
72
74 brian d foy, "<bdfoy@cpan.org>"
75
77 Copyright © 2008-2017, brian d foy "<bdfoy@cpan.org>". All rights
78 reserved.
79
80 This project is under the Artistic License 2.0.
81
82
83
84perl v5.30.0 2019-07-26 Module::Extract::Use(3)