line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Lyskom::Util; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
5
|
use base qw{Exporter}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
386
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our (@EXPORT_OK, %EXPORT_TAGS, $debug); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@EXPORT_OK = qw{ |
10
|
|
|
|
|
|
|
holl |
11
|
|
|
|
|
|
|
debug |
12
|
|
|
|
|
|
|
deholl |
13
|
|
|
|
|
|
|
parse_array_stream |
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
16
|
|
|
|
|
|
|
all => [qw { |
17
|
|
|
|
|
|
|
holl |
18
|
|
|
|
|
|
|
debug |
19
|
|
|
|
|
|
|
deholl |
20
|
|
|
|
|
|
|
parse_array_stream |
21
|
|
|
|
|
|
|
}] |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Net::Lyskom::Util - Utility functions for Net::Lyskom objects |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Net::Lyskom::Util qw{:all}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Holds a handful of utility functions. They are all exported via the :all tag. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 Functions |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item holl($arg) |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns its argument Hollerith-encoded. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item deholl($arg) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns its argument with Hollerith-encoding removed. Almost totally useless |
48
|
|
|
|
|
|
|
since the network processing also removes Hollerith encoding. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item debug(@arg) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Prints its arguments to STDERR if the variable $debug is set. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item parse_array_stream($cref,$aref) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Helper function for parsing arrays out of the stream returned from the |
57
|
|
|
|
|
|
|
Kom server. First argument should be a reference to a function that slurps |
58
|
|
|
|
|
|
|
items from an array given as reference argument to it, the second argument |
59
|
|
|
|
|
|
|
should be a reference to the array that should be slurped. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub holl { |
66
|
4
|
|
|
4
|
1
|
74
|
return length($_[0])."H".$_[0]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub deholl { |
70
|
0
|
|
|
0
|
1
|
0
|
my $r = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
$r =~ s/^\d+H//; |
73
|
0
|
|
|
|
|
0
|
return $r; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub debug { |
77
|
29
|
50
|
|
29
|
1
|
73
|
return unless $debug; |
78
|
0
|
|
|
|
|
0
|
print @_,"\n"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub parse_array_stream { |
82
|
6
|
|
|
6
|
1
|
56
|
my $proc = shift; |
83
|
6
|
|
|
|
|
12
|
my @res; |
84
|
6
|
|
|
|
|
8
|
my $count = shift @{$_[0]}; |
|
6
|
|
|
|
|
19
|
|
85
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
10
|
my $sign = shift @{$_[0]}; # Get the intial brace |
|
6
|
|
|
|
|
16
|
|
87
|
6
|
100
|
|
|
|
76
|
return () unless $sign eq "{"; |
88
|
|
|
|
|
|
|
|
89
|
5
|
|
|
|
|
30
|
while ($count-- > 0) { |
90
|
280
|
|
|
|
|
717
|
push @res, &$proc(@_); |
91
|
|
|
|
|
|
|
} |
92
|
5
|
|
|
|
|
47
|
shift @{$_[0]}; # Lose the closing brace |
|
5
|
|
|
|
|
12
|
|
93
|
5
|
|
|
|
|
1301
|
return @res; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return 1; |