5
module_info - find informations about modules
9
module_info [B<-a>] [B<-s>] [B<-p>] [B<-m>] MODULE|FILE...
13
List information about the arguments (either module names in the form
14
C<Module::Name> or paths in the form C<Foo/Bar.pm> or C<foo/bar.pl>).
16
By default only shows module name, version, directory, absolute path
17
and a flag indicating if it is a core module. Additional informations
18
can be requested through command line switches.
24
Show subroutines created by the module.
28
Show packages created by the module.
32
Show modules C<use()>d by the module.
36
Equivalent to C<-s -p -m>.
42
Mattia Barbon <mbarbon@cpan.org>
54
my( $show_subroutines, $show_modules, $show_packages, $show_all, $help );
56
GetOptions( 's' => \$show_subroutines,
57
'p' => \$show_packages,
58
'm' => \$show_modules,
63
if( $help || !@ARGV ) {
65
Usage: module_info [-a] [-s] [-p] [-m] MODULE|FILE...
67
-a Equivalent to -s -p -m
69
-m Show modules use()d by the module
70
-p Show packages created by the module
71
-s Show subroutines created by the module
76
$show_subroutines ||= $show_all;
77
$show_modules ||= $show_all;
78
$show_packages ||= $show_all;
82
foreach my $module (@ARGV) {
86
$info = Module::Info->new_from_file($module);
89
$info = Module::Info->new_from_module($module);
93
warn "Can't create Module::Info object for module '$module'";
98
$info->die_on_compilation_error(1);
100
my $name = $info->name || $module;
101
my $version = $info->version || '(unknown)';
102
my $dir = $info->inc_dir;
103
my $file = $info->file;
104
my $is_core = $info->is_core ? "yes" : "no";
112
Core module: $is_core
115
my %packages_created;
120
@modules_used = $info->modules_used if $show_modules;
121
%packages_created = $info->package_versions if $show_packages;
122
%subroutines = $info->subroutines if $show_subroutines;
125
warn "Compilation failed for module '$module'";
130
###########################################################################
132
###########################################################################
133
if( $show_modules ) {
134
print "\nModules used:\n";
135
foreach my $m (sort @modules_used) {
138
print " (none)\n" unless @modules_used;
141
###########################################################################
143
###########################################################################
144
if( $show_packages ) {
145
print "\nPackages created:\n";
146
foreach my $p (sort keys %packages_created) {
148
print +( defined( $packages_created{$p} ) ?
149
$packages_created{$p} :
153
print " (none)\n" unless keys %packages_created;
156
###########################################################################
158
###########################################################################
159
if( $show_subroutines ) {
160
print "\nSubroutines defined:\n";
163
sort { ( $a->[0] cmp $b->[0] ) || ( $a->[1] cmp $b->[1] ) }
165
my($package, $subname) = ($_ =~ m/^(.*)?::(\w+)$/);
166
warn "Strange subroutine '$_'"
167
unless $package || $subname;
168
$package ||= '(unknown)';
169
$subname ||= '(unknown)';
170
[ $package, $subname ];
172
my $prev_package = ':'; # impossible
173
foreach my $s (@subroutines) {
174
my($package, $subname) = @$s;
175
if($prev_package ne $package) {
176
$prev_package = $package;
183
print " (none)\n" unless %subroutines;