-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathx-perl-module-info
executable file
·63 lines (49 loc) · 1.08 KB
/
x-perl-module-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
#
# Loads a set of modules and print usefull information about them
#
# Pedro Melo <[email protected]> 2004/12/23
use strict;
use warnings;
usage() unless @ARGV;
my @report;
MODULE:
foreach my $module (@ARGV) {
my %info = ( name => $module );
push @report, \%info;
my $fname = "$module.pm";
$fname =~ s/::/\//g;
$info{file} = $fname;
eval "require $module";
if (my $e = $@) {
if ($e =~ /^Can't locate $fname/) {
$info{not_found} = 1;
}
else {
$info{not_loaded} = 1;
$info{error} = $e;
}
next MODULE;
}
$info{version} = $module->VERSION;
$info{path} = $INC{$fname};
}
foreach my $info (@report) {
my $name = $info->{name};
foreach my $f (qw( name version file path not_found not_loaded )) {
print "$name $f: $info->{$f}\n" if $info->{$f};
}
}
#######
# Usage
sub usage {
print <<EOU;
x-perl-module-version MODULE...
Loads all the MODULEs and print information about them:
* class name;
* version;
* relative file name;
* full path name of loaded version.
EOU
exit(1);
}