line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Mask; |
2
|
3
|
|
|
3
|
|
206251
|
use 5.006; use strict; use warnings; |
|
3
|
|
|
3
|
|
27
|
|
|
3
|
|
|
3
|
|
15
|
|
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
86
|
|
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
94
|
|
3
|
3
|
|
|
3
|
|
15
|
use base 'Import::Export'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1488
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
6
|
|
|
|
|
|
|
our %EX = ( |
7
|
|
|
|
|
|
|
mask => [qw/all/] |
8
|
|
|
|
|
|
|
); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub mask { |
11
|
30
|
|
|
30
|
1
|
245
|
my ($string, $pos, $length, $mask_char) = @_; |
12
|
30
|
|
100
|
|
|
85
|
$pos ||= 'start'; |
13
|
30
|
|
66
|
|
|
108
|
$length ||= int(length($string) / 2); |
14
|
30
|
100
|
|
|
|
95
|
if ($pos eq 'end') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
15
|
8
|
|
|
|
|
128
|
$string =~ s/(.*)(.{$length})$/_mask($1, $mask_char).$2/es; |
|
8
|
|
|
|
|
25
|
|
16
|
|
|
|
|
|
|
} elsif ($pos eq 'middle') { |
17
|
10
|
|
|
|
|
30
|
my $half = int((length($string) - $length) / 2); |
18
|
10
|
|
|
|
|
161
|
$string =~ s/(.{$half})(.{$length})(.*)/_mask($1, $mask_char).$2._mask($3, $mask_char)/e; |
|
10
|
|
|
|
|
31
|
|
19
|
|
|
|
|
|
|
} elsif ($pos eq 'email') { |
20
|
4
|
|
|
|
|
102
|
$string =~ s/(.*)(.{$length}\@.*)$/$1._mask($2, $mask_char)/e; |
|
4
|
|
|
|
|
14
|
|
21
|
|
|
|
|
|
|
} else { |
22
|
8
|
|
|
|
|
119
|
$string =~ s/(\w{$length})(.*)/$1._mask($2, $mask_char)/e; |
|
8
|
|
|
|
|
27
|
|
23
|
|
|
|
|
|
|
} |
24
|
30
|
|
|
|
|
132
|
return $string; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _mask { |
28
|
40
|
|
|
40
|
|
103
|
my ($string, $char) = @_; |
29
|
40
|
|
100
|
|
|
150
|
$char ||= '*'; |
30
|
40
|
|
|
|
|
228
|
$string =~ s/[^.@]/$char/g; |
31
|
40
|
|
|
|
|
165
|
return $string; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |