line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::DigestPath; |
2
|
2
|
|
|
2
|
|
59445
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
184
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
11
|
use Digest::MD5 qw//; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
80
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
9
|
2
|
|
|
|
|
20
|
rw => [qw/ salt depth delim digest trancate /], |
10
|
2
|
|
|
2
|
|
2012
|
); |
|
2
|
|
|
|
|
16023
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
1
|
13
|
my ($class, %args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $opt = { |
16
|
|
|
|
|
|
|
salt => defined $args{salt} ? delete $args{salt} : '', |
17
|
|
|
|
|
|
|
depth => defined $args{depth} ? int( delete $args{depth} ) : 4, |
18
|
|
|
|
|
|
|
delim => defined $args{delim} ? delete $args{delim} : '/', |
19
|
|
|
|
|
|
|
digest => ref $args{digest} eq 'CODE' ? delete $args{digest} |
20
|
11
|
|
|
11
|
|
121
|
: sub { Digest::MD5::md5_hex(@_) }, |
21
|
1
|
50
|
|
|
|
22
|
trancate => defined $args{trancate} ? delete $args{trancate} : undef, |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
4
|
bless $opt, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub make_path { |
28
|
11
|
|
|
11
|
1
|
1305
|
my ($self, $key, $length) = @_; |
29
|
|
|
|
|
|
|
|
30
|
11
|
100
|
|
|
|
30
|
$key = '' unless defined $key; |
31
|
|
|
|
|
|
|
|
32
|
11
|
|
|
|
|
28
|
my $hash = $self->digest->($self->salt . $key); |
33
|
11
|
100
|
|
|
|
32
|
my $path = join( |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->delim, |
35
|
|
|
|
|
|
|
(split '', $hash)[ 0 .. $self->depth - 1 ], |
36
|
|
|
|
|
|
|
$length |
37
|
|
|
|
|
|
|
? substr($hash, $self->trancate ? $self->depth : 0, $length) |
38
|
|
|
|
|
|
|
: substr($hash, $self->trancate ? $self->depth : 0) |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
11
|
|
|
|
|
295
|
return $path; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |