line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Filename; |
2
|
1
|
|
|
1
|
|
21687
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
789
|
use Path::Class qw{file}; |
|
1
|
|
|
|
|
55966
|
|
|
1
|
|
|
|
|
324
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Module::Filename - Returns the filename for a given module |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Module::Filename; |
13
|
|
|
|
|
|
|
my $filename=Module::Filename->new->filename("strict"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 USAGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 new |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $mf=Module::Filename->new(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
1
|
|
|
1
|
1
|
12
|
my $this = shift(); |
29
|
1
|
|
33
|
|
|
7
|
my $class = ref($this) || $this; |
30
|
1
|
|
|
|
|
2
|
my $self = {}; |
31
|
1
|
|
|
|
|
3
|
bless $self, $class; |
32
|
1
|
|
|
|
|
4
|
$self->initialize(@_); |
33
|
1
|
|
|
|
|
3
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub initialize { |
41
|
1
|
|
|
1
|
0
|
2
|
my $self = shift(); |
42
|
1
|
|
|
|
|
6
|
%$self=@_; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 filename |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns the first filename that matches the module in the @INC path array. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $filename=Module::Filename->new->filename("strict"); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub filename { |
54
|
5
|
|
|
5
|
1
|
493
|
my $self=shift; |
55
|
5
|
50
|
|
|
|
17
|
my $module=shift or die("Error: Module name required."); |
56
|
5
|
|
|
|
|
26
|
my $file=file(split("::", $module.".pm")); |
57
|
5
|
|
|
|
|
552
|
my $return=undef; |
58
|
5
|
|
|
|
|
12
|
foreach my $path (@INC) { |
59
|
49
|
|
|
|
|
2322
|
my $filename=file($path, $file); |
60
|
49
|
100
|
|
|
|
4330
|
if (-f $filename) { |
61
|
4
|
|
|
|
|
223
|
$return=$filename; |
62
|
4
|
|
|
|
|
7
|
last; #return the first match in @INC |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
5
|
|
|
|
|
78
|
return $return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 BUGS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Submit to RT and email author. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SUPPORT |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Try author. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Michael R. Davis |
79
|
|
|
|
|
|
|
CPAN ID: MRDVT |
80
|
|
|
|
|
|
|
STOP, LLC |
81
|
|
|
|
|
|
|
domain=>michaelrdavis,tld=>com,account=>perl |
82
|
|
|
|
|
|
|
http://www.stopllc.com/ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This program is free software licensed under the... |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The BSD License |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The full text of the license can be found in the |
91
|
|
|
|
|
|
|
LICENSE file included with this module. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SEE ALSO |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L, L constructor=>new_from_module, method=>file, L property=>"dir", L method=>locate, L method=>find_installed |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |