line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Filename::Convention; |
2
|
1
|
|
|
1
|
|
604
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
4
|
use File::Filename 'get_filename_segments'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
1
|
|
|
1
|
|
5
|
use vars qw(@ISA @EXPORT_OK $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
372
|
|
6
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
7
|
|
|
|
|
|
|
@EXPORT_OK = (qw(get_filename_hash)); |
8
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)/g; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub get_filename_hash { |
11
|
37
|
|
|
37
|
0
|
12300
|
my $filename = shift; |
12
|
37
|
|
|
|
|
41
|
my $filenamingconvention_fields = shift; |
13
|
37
|
|
|
|
|
39
|
my $filenamingconvention_matchsubs = shift; |
14
|
|
|
|
|
|
|
|
15
|
37
|
|
|
|
|
79
|
my $segments =get_filename_segments($filename); |
16
|
|
|
|
|
|
|
|
17
|
37
|
|
|
|
|
63
|
my $try=0; |
18
|
|
|
|
|
|
|
|
19
|
37
|
|
|
|
|
84
|
CONVENTION : |
20
|
37
|
|
|
|
|
42
|
for my $convention (@{$filenamingconvention_fields}){ |
21
|
|
|
|
|
|
|
|
22
|
65
|
|
|
|
|
69
|
++$try; |
23
|
|
|
|
|
|
|
### CONVENTION MATCH try: $try |
24
|
|
|
|
|
|
|
|
25
|
65
|
100
|
|
|
|
152
|
(scalar @$convention == scalar @$segments) or next; |
26
|
|
|
|
|
|
|
|
27
|
37
|
|
|
|
|
41
|
my $x=0; |
28
|
37
|
|
|
|
|
46
|
my $segment_hash={}; |
29
|
|
|
|
|
|
|
|
30
|
37
|
|
|
|
|
60
|
for my $segmentlabel (@$convention) { |
31
|
176
|
|
|
|
|
282
|
my $segmentcontent = @$segments[$x++]; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
### $segmentlabel |
34
|
|
|
|
|
|
|
### $segmentcontent |
35
|
|
|
|
|
|
|
|
36
|
176
|
50
|
|
|
|
297
|
defined $segmentlabel or next CONVENTION; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
### was def |
39
|
|
|
|
|
|
|
|
40
|
176
|
|
|
|
|
150
|
my $mustbe; |
41
|
176
|
100
|
|
|
|
330
|
if (ref $segmentlabel eq 'ARRAY'){ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
### was array: $segmentlabel |
44
|
3
|
|
|
|
|
7
|
($segmentlabel,$mustbe) = @$segmentlabel; |
45
|
|
|
|
|
|
|
### split into: $segmentlabel |
46
|
|
|
|
|
|
|
### must be: $mustbe |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
176
|
100
|
|
|
|
355
|
if (defined $filenamingconvention_matchsubs->{$segmentlabel}){ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
### has sub? |
53
|
|
|
|
|
|
|
|
54
|
106
|
100
|
|
|
|
104
|
&{$filenamingconvention_matchsubs->{$segmentlabel}}($segmentcontent) or do { |
|
106
|
|
|
|
|
267
|
|
55
|
|
|
|
|
|
|
### returns no for: $segmentcontent |
56
|
9
|
|
|
|
|
70
|
next CONVENTION; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
### had sub yes |
60
|
|
|
|
|
|
|
|
61
|
97
|
100
|
|
|
|
598
|
if(defined $mustbe){ |
62
|
|
|
|
|
|
|
### $mustbe |
63
|
2
|
50
|
|
|
|
979
|
$segmentcontent=~/^$mustbe$/i or next CONVENTION; |
64
|
|
|
|
|
|
|
### is |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
97
|
|
|
|
|
179
|
$segment_hash->{$segmentlabel} = $segmentcontent; |
68
|
97
|
|
|
|
|
154
|
next; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
70
|
|
|
|
|
171
|
$segment_hash->{$segmentlabel} = $segmentcontent; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
28
|
|
|
|
|
95
|
return $segment_hash; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
### $filename |
80
|
|
|
|
|
|
|
### matches no conventions |
81
|
|
|
|
|
|
|
### tries: $try |
82
|
9
|
|
|
|
|
28
|
return; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |