line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Validate::Terrorist; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
37372
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
37
|
use 5.008_005; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
191
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw/is_terrorist/; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
13
|
use Carp; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
904
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub is_terrorist { |
14
|
4
|
100
|
|
4
|
1
|
59
|
my $self = shift if ref($_[0]); # OO |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
18
|
my $name = join('', @_); |
17
|
4
|
|
|
|
|
16
|
$name = uc($name); |
18
|
4
|
|
|
|
|
16
|
$name =~ s/[[:^alpha:]]//g; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
18
|
my @data = __load_data(); |
21
|
4
|
50
|
|
|
|
431
|
return 1 if grep { $_ eq $name } @data; |
|
11464
|
|
|
|
|
14337
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# try reverse |
24
|
4
|
50
|
|
|
|
19
|
if (@_ > 1) { |
25
|
4
|
|
|
|
|
19
|
$name = join('', reverse @_); |
26
|
4
|
|
|
|
|
12
|
$name = uc($name); |
27
|
4
|
|
|
|
|
17
|
$name =~ s/[[:^alpha:]]//g; |
28
|
4
|
100
|
|
|
|
41
|
return 1 if grep { $_ eq $name } @data; |
|
11464
|
|
|
|
|
14470
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
233
|
return 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my @__data; |
35
|
|
|
|
|
|
|
sub __load_data { |
36
|
4
|
100
|
|
4
|
|
1766
|
return @__data if @__data; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
5
|
my $file = __FILE__; |
39
|
2
|
|
|
|
|
14
|
$file =~ s/\.pm/\.csv/; |
40
|
2
|
50
|
|
|
|
136
|
open(my $fh, '<', $file) or croak "Can't find $file, please re-install the module.\n"; |
41
|
2
|
|
|
|
|
3871
|
@__data = <$fh>; |
42
|
2
|
|
|
|
|
196
|
close($fh); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
282
|
chomp(@__data); |
45
|
2
|
|
|
|
|
1362
|
@__data; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# for OO |
49
|
|
|
|
|
|
|
sub new { |
50
|
1
|
|
|
1
|
0
|
13
|
my $class = shift; |
51
|
1
|
|
33
|
|
|
11
|
return bless {}, ref($class) || $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |