Lyskom/Util.pm

filter: Statementstmt 87.1% 27 / 31 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 4 / 4 totaltotal 87.5% 42 / 48 CC 4 SCAR 6.9
CC
4
Cov
86%
parse_array_stream
3.0
debug
2.5
deholl
2.0
CRAP 2.0
« Lyskom/Conference.pm ↑ Summary Lyskom/Person.pm »
1 package Net::Lyskom::Util;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw{Exporter};
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our (@EXPORT_OK, %EXPORT_TAGS, $debug);
8  
9 1 @EXPORT_OK = qw{
10 holl
11 debug
12 deholl
13 parse_array_stream
14 };
15 1 %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 4 ▶sub holl {
Subroutine holl: called CC=1 SCAR=0.0
Pod documented
66 4 return length($_[0])."H".$_[0];
67 }
68  
69 0 ▶sub deholl {
Subroutine deholl: not called CC=1 SCAR=6.9
Pod documented
70 0 my $r = shift;
71  
72 0 $r =~ s/^\d+H//;
73 0 return $r;
74 }
75  
76 29 ▶sub debug {
Subroutine debug: called CC=2 SCAR=9.2
Pod documented
77 29 ▶ return unless $debug;
Branch: 1 branch
BranchTrueFalseTotal
unless $Net::Lyskom::Util::debug 29 0 29
78 0 print @_,"\n";
79 }
80  
81 6 ▶sub parse_array_stream {
Subroutine parse_array_stream: called CC=3 SCAR=11.0
Pod documented
82 6 my $proc = shift;
83 6 my @res;
84 6 my $count = shift @{$_[0]};
85  
86 6 my $sign = shift @{$_[0]}; # Get the intial brace
87 6 ▶ return () unless $sign eq "{";
Branch: 1 branch
BranchTrueFalseTotal
unless $sign eq "{" 1 5 6
88  
89 5 ▶ while ($count-- > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count-- > 0) 130 5 135
90 130 push @res, &$proc(@_);
91 }
92 5 shift @{$_[0]}; # Lose the closing brace
93 5 return @res;
94 }
95  
96  
97 1 return 1;
« Lyskom/Conference.pm ↑ Summary Lyskom/Person.pm »