line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Remember::Util; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Data::Remember::Util::VERSION = '0.140490'; |
4
|
|
|
|
|
|
|
} |
5
|
11
|
|
|
11
|
|
59
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
380
|
|
6
|
11
|
|
|
11
|
|
53
|
use warnings; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
970
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
58
|
use Carp; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
1187
|
|
9
|
11
|
|
|
|
|
114
|
use Sub::Exporter -setup => { |
10
|
|
|
|
|
|
|
exports => [ qw( process_que init_brain ) ], |
11
|
11
|
|
|
11
|
|
19080
|
}; |
|
11
|
|
|
|
|
237599
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: common helper utilities |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub process_que { |
17
|
404
|
|
|
404
|
1
|
646
|
my $que = shift; |
18
|
|
|
|
|
|
|
|
19
|
404
|
|
|
|
|
494
|
my @ques; |
20
|
404
|
100
|
|
|
|
1245
|
if (ref $que eq 'ARRAY') { |
|
|
50
|
|
|
|
|
|
21
|
162
|
|
|
|
|
480
|
@ques = @$que; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
elsif (ref $que eq 'HASH') { |
25
|
0
|
|
|
|
|
0
|
for my $key (sort keys %$que) { |
26
|
0
|
|
|
|
|
0
|
push @ques, $key, $que->{$key}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
else { |
31
|
242
|
|
|
|
|
770
|
@ques = ($que); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
404
|
|
|
|
|
857
|
for my $que (@ques) { |
35
|
768
|
100
|
|
|
|
2165
|
return undef unless defined $que; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
403
|
|
|
|
|
1382
|
return \@ques; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub init_brain { |
43
|
19
|
|
|
19
|
1
|
44
|
my $brain = shift; |
44
|
|
|
|
|
|
|
|
45
|
19
|
50
|
|
|
|
120
|
$brain = 'Data::Remember::' . $brain |
46
|
|
|
|
|
|
|
unless $brain =~ /::/; |
47
|
|
|
|
|
|
|
|
48
|
19
|
50
|
|
|
|
178
|
$brain =~ /^[\w:]+$/ |
49
|
|
|
|
|
|
|
or croak qq{This does not look like a valid brain: $brain}; |
50
|
|
|
|
|
|
|
|
51
|
19
|
50
|
|
|
|
94
|
Class::Load::load_class($brain) |
52
|
|
|
|
|
|
|
or carp qq{The brain $brain may not have loaded correctly: $@}; |
53
|
|
|
|
|
|
|
|
54
|
19
|
|
|
|
|
848
|
my $gray_matter = $brain->new(@_); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Duck typing! |
57
|
19
|
50
|
|
|
|
60101
|
$gray_matter->can('remember') |
58
|
|
|
|
|
|
|
or croak qq{Your brain cannot remember facts: $brain}; |
59
|
19
|
50
|
|
|
|
112
|
$gray_matter->can('recall') |
60
|
|
|
|
|
|
|
or croak qq{Your brain cannot recall facts: $brain}; |
61
|
19
|
50
|
|
|
|
96
|
$gray_matter->can('forget') |
62
|
|
|
|
|
|
|
or croak qq{Your brain cannot forget facts: $brain}; |
63
|
|
|
|
|
|
|
|
64
|
19
|
|
|
|
|
137
|
return $gray_matter; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |