NAME
Module::Installed - Check whether a module, or a file's list of includes are installed.

SYNOPSIS
use Module::Installed qw(module_installed includes_installed)
# module_installed()
if (module_installed('Mock::Sub')) {
require $module;
$module->import;
...
}
else {
warn "$module is not installed...";
}
# includes_installed()
my $includes = includes_installed('perl_file_with_includes.pl');
for my $inc_name (keys %$includes) {
my $statement = $includes->{$inc_name}
? "is installed"
: "isn't installed";
print "$inc_name $statement\n";
}
DESCRIPTION
Verifies whether or not a module or a file's list of includes are installed.
FUNCTIONS
module_installed($name)
Checks whether a module is installed on your system.
Parameters:
$name
Mandatory, String: The name of the module to check against (eg: Mock::Sub
).
Returns: True (1
) if the module is found, and false (0
) if not.
includes_installed($file)
This function reads in a Perl file, strips out all of its includes (use
and require
), and checks whether each one is installed on the system.
Note: This function requires PPI to be installed. If it is, we'll load it and proceed. If it isn't, we croak()
.
Parameters:
$file
Mandatory, String: The name of a Perl file.
Returns: A hash reference where the found included modules' name as the key, and for the value, true (1
) if the module is installed and false (0
) if not.
SEE ALSO
This module was pretty well copy/pasted from Module::Installed::Tiny, but without the significant dependency chain required by that distributions test suite.
AUTHOR
Steve Bertrand <steveb@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Steve Bertrand
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.