line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Manipulator; |
2
|
2
|
|
|
2
|
|
134917
|
use 5.006; use strict; use warnings; |
|
2
|
|
|
2
|
|
17
|
|
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
92
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
2
|
|
|
2
|
|
2482
|
use overload '&{}' => 'engage'; |
|
2
|
|
|
|
|
2112
|
|
|
2
|
|
|
|
|
11
|
|
5
|
2
|
|
|
2
|
|
1147
|
use Tie::IxHash; |
|
2
|
|
|
|
|
8735
|
|
|
2
|
|
|
|
|
60
|
|
6
|
2
|
|
|
2
|
|
15
|
use base 'Import::Export'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
972
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our %EX = ( |
9
|
|
|
|
|
|
|
manipulate => [qw/all/], |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub manipulate { |
13
|
|
|
|
|
|
|
my (%args) = (scalar @_ > 1 |
14
|
|
|
|
|
|
|
? @_ |
15
|
|
|
|
|
|
|
: ref $_[0] eq 'CODE' |
16
|
|
|
|
|
|
|
? (code => $_[0]) |
17
|
|
|
|
|
|
|
: ref $_[0] eq 'HASH' |
18
|
0
|
|
|
|
|
0
|
? %{ $_[0] } |
19
|
2
|
0
|
|
2
|
0
|
649
|
: @{ $_[0] } |
|
0
|
50
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
20
|
|
|
|
|
|
|
); |
21
|
2
|
|
|
|
|
15
|
bless \%args, __PACKAGE__; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub engage { |
25
|
3
|
|
|
3
|
0
|
54
|
my ($self) = shift; |
26
|
|
|
|
|
|
|
return sub { |
27
|
3
|
|
|
3
|
|
11
|
my (@params) = @_; |
28
|
|
|
|
|
|
|
|
29
|
3
|
50
|
|
|
|
8
|
if (scalar @params == 1) { |
30
|
0
|
|
|
|
|
0
|
my $hash = shift @params; |
31
|
0
|
|
|
|
|
0
|
@params = map {($_, $hash->{$_})} sort { $a <=> $b } keys %{$hash}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
100
|
|
|
|
5
|
if (scalar keys %{$self} > 1) { |
|
3
|
|
|
|
|
13
|
|
35
|
2
|
|
|
|
|
8
|
for (my $i = 0; $i < scalar @params; $i += 2) { |
36
|
4
|
|
|
|
|
20
|
my ($key, $value) = ($params[$i], $params[$i + 1]); |
37
|
4
|
|
|
|
|
10
|
$params[$i + 1] = $self->{$key}->($value); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} else { |
40
|
1
|
|
|
|
|
4
|
for (my $i = 0; $i < scalar @params; $i++) { |
41
|
4
|
|
|
|
|
17
|
$params[$i] = $self->{code}->($params[$i]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
3
|
100
|
|
|
|
29
|
return wantarray ? @params : {@params}; |
46
|
3
|
|
|
|
|
14
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub ordered { |
50
|
1
|
|
|
1
|
0
|
964
|
my ($self, @params) = @_; |
51
|
1
|
|
|
|
|
5
|
my @data = $self->(@params); |
52
|
1
|
|
|
|
|
9
|
my %out; tie %out, 'Tie::IxHash', @data; |
|
1
|
|
|
|
|
13
|
|
53
|
1
|
50
|
|
|
|
75
|
return wantarray ? %out : \%out; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |