line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::NumericData::App::txdmean; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
72434
|
use Text::NumericData::App; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
452
|
|
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
|
99
|
my $class = shift; |
25
|
1
|
|
|
|
|
2
|
my @pars = (); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
23
|
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
|
89
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
10
|
$self->new_txd(); |
49
|
1
|
|
|
|
|
4
|
$self->{mean} = []; |
50
|
1
|
|
|
|
|
2
|
$self->{ln} = 0; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
4
|
return 0; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ignore |
56
|
|
|
|
|
|
|
{ |
57
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
58
|
2
|
|
|
|
|
4
|
$_[0] = ''; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub process_data |
62
|
|
|
|
|
|
|
{ |
63
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
20
|
my $data = $self->{txd}->line_data($_[0]); |
66
|
4
|
|
|
|
|
9
|
$_[0] = ''; |
67
|
4
|
50
|
|
|
|
5
|
return unless @{$data}; |
|
4
|
|
|
|
|
10
|
|
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
8
|
++$self->{ln}; |
70
|
|
|
|
|
|
|
|
71
|
4
|
100
|
|
|
|
7
|
if(@{$self->{mean}}) |
|
4
|
|
|
|
|
10
|
|
72
|
|
|
|
|
|
|
{ |
73
|
3
|
|
|
|
|
6
|
for(my $i = 0; $i <= $#{$self->{mean}}; ++$i) |
|
12
|
|
|
|
|
40
|
|
74
|
|
|
|
|
|
|
{ |
75
|
9
|
|
|
|
|
21
|
$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
|
|
|
|
|
11
|
|
90
|
|
|
|
|
|
|
{ |
91
|
3
|
|
|
|
|
7
|
$self->{mean}[$i] /= $self->{ln}; |
92
|
|
|
|
|
|
|
} |
93
|
1
|
|
|
|
|
2
|
$_[0] = ${$self->{txd}->data_line($self->{mean})}; |
|
1
|
|
|
|
|
6
|
|
94
|
|
|
|
|
|
|
} |