1ExtUtils::Installed(3)User Contributed Perl DocumentationExtUtils::Installed(3)
2
3
4
6 ExtUtils::Installed - Inventory management of installed modules
7
9 use ExtUtils::Installed;
10 my ($inst) = ExtUtils::Installed->new( skip_cwd => 1 );
11 my (@modules) = $inst->modules();
12 my (@missing) = $inst->validate("DBI");
13 my $all_files = $inst->files("DBI");
14 my $files_below_usr_local = $inst->files("DBI", "all", "/usr/local");
15 my $all_dirs = $inst->directories("DBI");
16 my $dirs_below_usr_local = $inst->directory_tree("DBI", "prog");
17 my $packlist = $inst->packlist("DBI");
18
20 ExtUtils::Installed provides a standard way to find out what core and
21 module files have been installed. It uses the information stored in
22 .packlist files created during installation to provide this
23 information. In addition it provides facilities to classify the
24 installed files and to extract directory information from the .packlist
25 files.
26
28 The new() function searches for all the installed .packlists on the
29 system, and stores their contents. The .packlists can be queried with
30 the functions described below. Where it searches by default is
31 determined by the settings found in %Config::Config, and what the value
32 is of the PERL5LIB environment variable.
33
35 Unless specified otherwise all method can be called as class methods,
36 or as object methods. If called as class methods then the "default"
37 object will be used, and if necessary created using the current
38 processes %Config and @INC. See the 'default' option to new() for
39 details.
40
41 new()
42 This takes optional named parameters. Without parameters, this
43 searches for all the installed .packlists on the system using
44 information from %Config::Config and the default module search
45 paths @INC. The packlists are read using the ExtUtils::Packlist
46 module.
47
48 If the named parameter "skip_cwd" is true, the current directory
49 "." will be stripped from @INC before searching for .packlists.
50 This keeps ExtUtils::Installed from finding modules installed in
51 other perls that happen to be located below the current directory.
52
53 If the named parameter "config_override" is specified, it should be
54 a reference to a hash which contains all information usually found
55 in %Config::Config. For example, you can obtain the configuration
56 information for a separate perl installation and pass that in.
57
58 my $yoda_cfg = get_fake_config('yoda');
59 my $yoda_inst =
60 ExtUtils::Installed->new(config_override=>$yoda_cfg);
61
62 Similarly, the parameter "inc_override" may be a reference to an
63 array which is used in place of the default module search paths
64 from @INC.
65
66 use Config;
67 my @dirs = split(/\Q$Config{path_sep}\E/, $ENV{PERL5LIB});
68 my $p5libs = ExtUtils::Installed->new(inc_override=>\@dirs);
69
70 Note: You probably do not want to use these options alone, almost
71 always you will want to set both together.
72
73 The parameter "extra_libs" can be used to specify additional paths
74 to search for installed modules. For instance
75
76 my $installed =
77 ExtUtils::Installed->new(extra_libs=>["/my/lib/path"]);
78
79 This should only be necessary if /my/lib/path is not in PERL5LIB.
80
81 Finally there is the 'default', and the related 'default_get' and
82 'default_set' options. These options control the "default" object
83 which is provided by the class interface to the methods. Setting
84 "default_get" to true tells the constructor to return the default
85 object if it is defined. Setting "default_set" to true tells the
86 constructor to make the default object the constructed object.
87 Setting the "default" option is like setting both to true. This is
88 used primarily internally and probably isn't interesting to any
89 real user.
90
91 modules()
92 This returns a list of the names of all the installed modules. The
93 perl 'core' is given the special name 'Perl'.
94
95 files()
96 This takes one mandatory parameter, the name of a module. It
97 returns a list of all the filenames from the package. To obtain a
98 list of core perl files, use the module name 'Perl'. Additional
99 parameters are allowed. The first is one of the strings "prog",
100 "doc" or "all", to select either just program files, just manual
101 files or all files. The remaining parameters are a list of
102 directories. The filenames returned will be restricted to those
103 under the specified directories.
104
105 directories()
106 This takes one mandatory parameter, the name of a module. It
107 returns a list of all the directories from the package. Additional
108 parameters are allowed. The first is one of the strings "prog",
109 "doc" or "all", to select either just program directories, just
110 manual directories or all directories. The remaining parameters
111 are a list of directories. The directories returned will be
112 restricted to those under the specified directories. This method
113 returns only the leaf directories that contain files from the
114 specified module.
115
116 directory_tree()
117 This is identical in operation to directories(), except that it
118 includes all the intermediate directories back up to the specified
119 directories.
120
121 validate()
122 This takes one mandatory parameter, the name of a module. It
123 checks that all the files listed in the modules .packlist actually
124 exist, and returns a list of any missing files. If an optional
125 second argument which evaluates to true is given any missing files
126 will be removed from the .packlist
127
128 packlist()
129 This returns the ExtUtils::Packlist object for the specified
130 module.
131
132 version()
133 This returns the version number for the specified module.
134
136 See the example in ExtUtils::Packlist.
137
139 Alan Burlison <Alan.Burlison@uk.sun.com>
140
141
142
143perl v5.32.1 2021-01-27 ExtUtils::Installed(3)