Devel::Modlist - Perl extension to collect module use information
perl -d:Modlist script.pl
The Devel::Modlist utility is provided as a means by which to get a quick run-down on which libraries and modules are being utilized by a given script.
Just as compiler systems like gcc provide dependancy information via
switches such as
-M, Devel::Modlist is intended to assist script authors
in preparing dependancy information for potential users of their scripts.
Usage of Devel::Modlist is simple. The primary method of invocation is to
-d option of Perl:
perl -d:Modlist script.pl
Alternately, one could use the
perl -MDevel::Modlist script.pl
In the case of this module, the two are identical save for the amount of typing (and option passing, see below). It is not recommended that this module be loaded directly by a script via the use keyword, as that would cause the dependancy reporting after every invocation until it was removed from the code.
The following options may be specified to the package. These are specified either by:
Options may also be given in an environment variable, which gets read at any invocation in which there are no options explicitly provided. If any options are given in the invocation, then the environment variable is ignored. Two different names are recognized:
The latter is to accomodate shells that do not like the presence of
an environment variable name.
installcommand to ensure that all needed modules are in fact present.
$VERSIONin the package namespace, Devel::Modlist finds this and includes it in the report by default. Use this option to override that default.
0) as the default version if the package has not provided a value. Otherwise, an empty string is displayed (unless noversion is given).
(Experimental, some options and/or features may change in future releases.)
If any yaml option is present, the output format is in YAML rather than
simple text. Additionally, the options can exert a degree of control
over the format of the resulting YAML. Those options that take value must
provide them by using a
= character immediately followed by the value, with
no space surrounding the
Requires. If you wish to suppress this header entirely, pass the special value
none, then this is not given a default, thus allowing the lines to be left-flush in the absence of the header. If you wish the lines to have no indentation, pass this option with a value of
0; the default is only applied if the option is not explicitly present. The indentation is relative to the value of yamlheaderindent, so if you provide a non-zero value for that option, it will be added to this one (unless the header is suppressed by
---separator. yamlheader may still be set to
noneto supress the header, even when a complete document is being generated.
The yaml option is just to allow selection of the YAML option without making any adjustments to the formatting. If any of the other YAML options are present, it will trigger this output format; an explicit yaml would be unnecessary.
The YAML output format respects other options (stdout, noversion, zerodefault, etc.). If noversion is given, the output is a sequential list rather than key/value pairings. If path is given, the keys (or values of the sequential list) are pathnames. Whether pathnames or module names are used, those values are always explicitly quoted in the YAML output.
Perl versions up to 5.6.0 cannot accept options to the
-d: flag as
-M flag. Thus, to pass options one must use:
Unfortunately, this inhibits the stop option detailed earlier. To use this option, an invocation of:
perl -d:Modlist -MDevel::Modlist=option1[,option2,...]
does the trick, as the first invocation puts the interpreter in debugging mode (necessary for stop to work) while the second causes the options to be parsed and recorded by Devel::Modlist.
Versions of Perl from 5.6.1 onwards allow options to be included with the
Because Devel::Modlist uses the
strict pragma internally (as all modules
should), that pragma is always removed from the output to avoid generating a
Randy J. Ray <email@example.com>, using idea and prototype code provided by Tim Bunce <Tim.Bunce@ig.co.uk>
This module and the code within are released under the terms of the Artistic License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php). This code may be redistributed under either the Artistic License or the GNU Lesser General Public License (LGPL) version 2.1 (http://www.opensource.org/licenses/lgpl-2.1.php).