line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::CSV::R::Matrix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
205
|
|
6
|
5
|
|
|
5
|
|
31
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
162
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
28
|
use Carp; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
394
|
|
9
|
5
|
|
|
5
|
|
4909
|
use Tie::Array; |
|
5
|
|
|
|
|
7710
|
|
|
5
|
|
|
|
|
171
|
|
10
|
5
|
|
|
5
|
|
43
|
use Scalar::Util qw(reftype looks_like_number); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
6217
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = 'Tie::Array'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub TIEARRAY { |
17
|
27
|
|
|
27
|
|
47
|
my ($self) = @_; |
18
|
27
|
|
|
|
|
235
|
return bless { ARRAY => [], ROWNAMES => [], COLNAMES => [], }, $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub FETCH { |
22
|
243
|
|
|
243
|
|
513
|
my ( $self, $index ) = @_; |
23
|
243
|
|
|
|
|
1297
|
return $self->{ARRAY}->[$index]; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub STORE { |
27
|
110
|
|
|
110
|
|
514
|
my ( $self, $index, $value ) = @_; |
28
|
110
|
|
|
|
|
218
|
$self->{ARRAY}->[$index] = $value; |
29
|
110
|
|
|
|
|
309
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub FETCHSIZE { |
33
|
337
|
|
|
337
|
|
1724
|
my $self = shift; |
34
|
337
|
|
|
|
|
403
|
return scalar @{ $self->{ARRAY} }; |
|
337
|
|
|
|
|
1694
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub STORESIZE { |
38
|
1
|
|
|
1
|
|
6
|
my ( $self, $value ) = @_; |
39
|
1
|
|
|
|
|
2
|
$#{ $self->{ARRAY} } = $value - 1; |
|
1
|
|
|
|
|
3
|
|
40
|
1
|
|
|
|
|
2
|
$#{ $self->{ROWNAMES} } = $value - 1; |
|
1
|
|
|
|
|
5
|
|
41
|
1
|
|
|
|
|
3
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub EXTEND { |
45
|
0
|
|
|
0
|
|
0
|
my ( $self, $count ) = @_; |
46
|
0
|
|
|
|
|
0
|
$self->STORESIZE($count); |
47
|
0
|
|
|
|
|
0
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub SPLICE { |
51
|
23
|
|
|
23
|
|
742
|
my $ob = shift; |
52
|
23
|
|
|
|
|
45
|
my $sz = $ob->FETCHSIZE; |
53
|
23
|
50
|
|
|
|
56
|
my $off = @_ ? shift : 0; |
54
|
23
|
50
|
|
|
|
57
|
if ( $off < 0 ) { |
55
|
0
|
|
|
|
|
0
|
$off += $sz; |
56
|
|
|
|
|
|
|
} |
57
|
23
|
50
|
|
|
|
47
|
my $len = @_ ? shift : $sz - $off; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# if LIST provided, empty new ROWNAMES |
60
|
23
|
|
|
|
|
48
|
my @rn = map {q{}} @_; |
|
1
|
|
|
|
|
3
|
|
61
|
23
|
|
|
|
|
26
|
splice @{ $ob->{ROWNAMES} }, $off, $len, @rn; |
|
23
|
|
|
|
|
70
|
|
62
|
23
|
|
|
|
|
30
|
return splice @{ $ob->{ARRAY} }, $off, $len, @_; |
|
23
|
|
|
|
|
127
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub COLNAMES { |
66
|
57
|
|
|
57
|
1
|
188
|
my ( $self, $values ) = @_; |
67
|
57
|
100
|
|
|
|
156
|
if ( defined $values ) { |
68
|
36
|
100
|
|
|
|
375
|
if ( !_is_array_ref($values) ) { |
69
|
2
|
|
|
|
|
274
|
croak 'Invalid colnames length'; |
70
|
|
|
|
|
|
|
} |
71
|
34
|
|
|
|
|
80
|
$self->{COLNAMES} = $values; |
72
|
|
|
|
|
|
|
} |
73
|
55
|
|
|
|
|
347
|
return $self->{COLNAMES}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub ROWNAMES { |
77
|
38
|
|
|
38
|
1
|
55
|
my ( $self, $values ) = @_; |
78
|
38
|
100
|
|
|
|
88
|
if ( defined $values ) { |
79
|
30
|
100
|
100
|
|
|
53
|
if ( !_is_array_ref($values) |
|
28
|
|
|
|
|
51
|
|
80
|
28
|
|
|
|
|
126
|
|| scalar @{$values} != scalar @{ $self->{ARRAY} } ) |
81
|
|
|
|
|
|
|
{ |
82
|
3
|
|
|
|
|
552
|
croak 'Invalid rownames length'; |
83
|
|
|
|
|
|
|
} |
84
|
27
|
|
|
|
|
52
|
$self->{ROWNAMES} = $values; |
85
|
|
|
|
|
|
|
} |
86
|
35
|
|
|
|
|
149
|
return $self->{ROWNAMES}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _is_array_ref { |
90
|
66
|
|
|
66
|
|
84
|
my ($values) = @_; |
91
|
66
|
100
|
100
|
|
|
626
|
return ( defined reftype $values && reftype $values eq 'ARRAY' ) ? 1 : 0; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |