line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::NumericData::App::txdmean; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
72097
|
use Text::NumericData::App; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
427
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is just a placeholder because of a past build system bug. |
8
|
|
|
|
|
|
|
# The one and only version for Text::NumericData is kept in |
9
|
|
|
|
|
|
|
# the Text::NumericData module itself. |
10
|
|
|
|
|
|
|
our $VERSION = '1'; |
11
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $infostring = 'find means in textual data files |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Usage: |
16
|
|
|
|
|
|
|
txdmean < data.dat |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
should result in a line with the mean values being printed'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @ISA = ('Text::NumericData::App'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new |
23
|
|
|
|
|
|
|
{ |
24
|
1
|
|
|
1
|
0
|
145
|
my $class = shift; |
25
|
1
|
|
|
|
|
3
|
my @pars = (); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
15
|
return $class->SUPER::new |
28
|
|
|
|
|
|
|
({ |
29
|
|
|
|
|
|
|
parconf => |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
info=>$infostring # default version |
32
|
|
|
|
|
|
|
# default author |
33
|
|
|
|
|
|
|
# default copyright |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
,pardef => \@pars |
36
|
|
|
|
|
|
|
,pipemode => 1 |
37
|
|
|
|
|
|
|
,pipe_begin => \&init |
38
|
|
|
|
|
|
|
,pipe_header => \&ignore |
39
|
|
|
|
|
|
|
,pipe_data => \&process_data |
40
|
|
|
|
|
|
|
,pipe_end => \&result |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub init |
45
|
|
|
|
|
|
|
{ |
46
|
1
|
|
|
1
|
0
|
112
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
14
|
$self->new_txd(); |
49
|
1
|
|
|
|
|
12
|
$self->{mean} = []; |
50
|
1
|
|
|
|
|
3
|
$self->{ln} = 0; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
7
|
return 0; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ignore |
56
|
|
|
|
|
|
|
{ |
57
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
58
|
2
|
|
|
|
|
5
|
$_[0] = ''; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub process_data |
62
|
|
|
|
|
|
|
{ |
63
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
14
|
my $data = $self->{txd}->line_data($_[0]); |
66
|
4
|
|
|
|
|
16
|
$_[0] = ''; |
67
|
4
|
50
|
|
|
|
6
|
return unless @{$data}; |
|
4
|
|
|
|
|
12
|
|
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
12
|
++$self->{ln}; |
70
|
|
|
|
|
|
|
|
71
|
4
|
100
|
|
|
|
7
|
if(@{$self->{mean}}) |
|
4
|
|
|
|
|
16
|
|
72
|
|
|
|
|
|
|
{ |
73
|
3
|
|
|
|
|
12
|
for(my $i = 0; $i <= $#{$self->{mean}}; ++$i) |
|
12
|
|
|
|
|
50
|
|
74
|
|
|
|
|
|
|
{ |
75
|
9
|
|
|
|
|
22
|
$self->{mean}[$i] += $data->[$i]; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
{ |
80
|
1
|
|
|
|
|
3
|
$self->{mean} = $data; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub result |
85
|
|
|
|
|
|
|
{ |
86
|
1
|
|
|
1
|
0
|
36
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# If no data there, nothing will happen. |
89
|
1
|
|
|
|
|
4
|
for(my $i = 0; $i <= $#{$self->{mean}}; ++$i) |
|
4
|
|
|
|
|
12
|
|
90
|
|
|
|
|
|
|
{ |
91
|
3
|
|
|
|
|
7
|
$self->{mean}[$i] /= $self->{ln}; |
92
|
|
|
|
|
|
|
} |
93
|
1
|
|
|
|
|
3
|
$_[0] = ${$self->{txd}->data_line($self->{mean})}; |
|
1
|
|
|
|
|
4
|
|
94
|
|
|
|
|
|
|
} |