line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YVDHOVE::List; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26760
|
use 5.008000; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
895
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( ArrayToDelimitedList |
13
|
|
|
|
|
|
|
HashToDelimitedList |
14
|
|
|
|
|
|
|
DelimitedListToArray |
15
|
|
|
|
|
|
|
DelimitedListToHash |
16
|
|
|
|
|
|
|
DelimitedKeyValuePairToHash ) ] ); |
17
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }); |
18
|
|
|
|
|
|
|
our @EXPORT = (); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub ArrayToDelimitedList($$$) { |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
1
|
15
|
my ($myArrayRef, $delimiter, $debug) = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
2
|
my $list = ''; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
4
|
if( @$myArrayRef ) { |
31
|
1
|
|
|
|
|
8
|
@$myArrayRef = sort(@$myArrayRef); |
32
|
1
|
|
|
|
|
4
|
$list = join($delimiter, @$myArrayRef); |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
0
|
$list = ''; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
3
|
return $list; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub HashToDelimitedList($$$) { |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
1
|
12
|
my ($myHASH, $delimiter, $debug) = @_; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
2
|
my $list = ''; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
6
|
for my $key ( sort keys %$myHASH ) { |
49
|
4
|
|
|
|
|
11
|
$list .= $key . $delimiter; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
4
|
chop($list); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
return $list; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub DelimitedListToArray($$$$) { |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
2
|
1
|
17
|
my ($myList, $delimiter, $count, $debug) = @_; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
4
|
my @myArray = (); |
64
|
|
|
|
|
|
|
|
65
|
2
|
50
|
33
|
|
|
13
|
if (defined $myList && $myList ne '') { |
66
|
2
|
|
|
|
|
20
|
my @items = split(/$delimiter/, $myList); |
67
|
2
|
|
|
|
|
5
|
my $number = 0; my $value = ''; |
|
2
|
|
|
|
|
3
|
|
68
|
2
|
|
|
|
|
4
|
foreach my $item (@items) { |
69
|
8
|
|
|
|
|
10
|
$value .= $item . $delimiter; |
70
|
8
|
|
|
|
|
8
|
$number++; |
71
|
8
|
100
|
|
|
|
17
|
if ($number == $count) { |
72
|
6
|
|
|
|
|
8
|
chop($value); |
73
|
6
|
|
|
|
|
9
|
push( @myArray, $value ); |
74
|
6
|
|
|
|
|
5
|
$value = ''; $number = 0; |
|
6
|
|
|
|
|
11
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
2
|
|
|
|
|
7
|
@myArray = sort(@myArray); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
5
|
return \@myArray; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub DelimitedListToHash($$$$) { |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
2
|
1
|
19
|
my ($myList, $delimiter, $count, $debug) = @_; |
88
|
2
|
50
|
33
|
|
|
22
|
my @items = split (/$delimiter/, $myList) if (defined $myList && $myList ne ''); |
89
|
2
|
|
|
|
|
5
|
my $number = 0; my $key = ''; |
|
2
|
|
|
|
|
3
|
|
90
|
2
|
|
|
|
|
3
|
my %myHASH = (); |
91
|
|
|
|
|
|
|
|
92
|
2
|
|
|
|
|
3
|
foreach my $item (@items) { |
93
|
8
|
|
|
|
|
10
|
$key .= $item . $delimiter; |
94
|
8
|
|
|
|
|
8
|
$number++; |
95
|
|
|
|
|
|
|
|
96
|
8
|
100
|
|
|
|
23
|
if ($number == $count) { |
97
|
6
|
|
|
|
|
8
|
chop $key; |
98
|
6
|
|
|
|
|
7
|
$myHASH{$key} = undef; |
99
|
6
|
|
|
|
|
7
|
$key = ''; |
100
|
6
|
|
|
|
|
12
|
$number = 0; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
7
|
return \%myHASH; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub DelimitedKeyValuePairToHash($$$) { |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
1
|
1
|
8
|
my ($myList, $delimiter, $debug) = @_; |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
1
|
|
1389
|
use Tie::IxHash; |
|
1
|
|
|
|
|
5695
|
|
|
1
|
|
|
|
|
151
|
|
114
|
1
|
|
|
|
|
2
|
my %myHASH; |
115
|
1
|
|
|
|
|
9
|
tie(%myHASH, 'Tie::IxHash'); |
116
|
1
|
|
|
|
|
21
|
%myHASH = map { my ($key, $value) = split (/=/) } split (/$delimiter/, $myList); |
|
2
|
|
|
|
|
21
|
|
117
|
|
|
|
|
|
|
|
118
|
1
|
50
|
|
|
|
52
|
if($debug) { |
119
|
0
|
|
|
|
|
0
|
print "Delimited List: " . $myList . "\n"; |
120
|
0
|
|
|
|
|
0
|
print "Size of myHASH: " . keys( %myHASH ) . "\n"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
3
|
return \%myHASH; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------- |
131
|
|
|
|
|
|
|
__END__ |