line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Path.pm |
2
|
|
|
|
|
|
|
# author 'Rolf Veen' |
3
|
|
|
|
|
|
|
# license zlib |
4
|
|
|
|
|
|
|
# date 20030609 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package OGDL::Path; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
9
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
779
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# takes a string and returns a list |
14
|
|
|
|
|
|
|
# with the path elements |
15
|
|
|
|
|
|
|
sub path2list |
16
|
|
|
|
|
|
|
{ |
17
|
19
|
|
|
19
|
0
|
23
|
my @l; |
18
|
19
|
|
|
|
|
29
|
my $s = $_[0]; |
19
|
19
|
|
|
|
|
28
|
my $len = length($s); |
20
|
19
|
|
|
|
|
24
|
my $state = 0; |
21
|
19
|
|
|
|
|
24
|
my $ix = 0; |
22
|
19
|
|
|
|
|
21
|
my $i=0; |
23
|
19
|
|
|
|
|
36
|
my $j=0; |
24
|
19
|
|
|
|
|
22
|
my $n=0; |
25
|
|
|
|
|
|
|
|
26
|
19
|
|
|
|
|
96
|
foreach my $c (split //, $s) { |
27
|
|
|
|
|
|
|
|
28
|
205
|
100
|
33
|
|
|
395
|
if ($state == 0) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
29
|
193
|
100
|
100
|
|
|
733
|
if ( $c eq "." ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
30
|
35
|
100
|
|
|
|
70
|
if ($n != 0) { $l[$ix++] = substr($s,$j,$i-$j); } |
|
28
|
|
|
|
|
74
|
|
31
|
35
|
|
|
|
|
55
|
$l[$ix++] = "."; |
32
|
35
|
|
|
|
|
38
|
$j = $i+1; |
33
|
35
|
|
|
|
|
37
|
$n = 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif ( $c eq "\"") { |
36
|
0
|
|
|
|
|
0
|
$state = 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( $c eq "'") { |
39
|
0
|
|
|
|
|
0
|
$state = 2; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( ($c eq "[") && ($n > 0)) { |
42
|
7
|
|
|
|
|
40
|
$l[$ix++] = substr($s,$j,$i-$j); |
43
|
7
|
|
|
|
|
9
|
$j = $i; |
44
|
7
|
|
|
|
|
10
|
$state = 3; |
45
|
7
|
|
|
|
|
10
|
$n = 0; |
46
|
|
|
|
|
|
|
} |
47
|
151
|
|
|
|
|
171
|
else { $n++; } |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif ( ($state == 1) && ($c eq '"')) { |
50
|
0
|
|
|
|
|
0
|
$state = 0; |
51
|
0
|
|
|
|
|
0
|
$n++; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ( ($state == 2) && ($c eq '\'')) { |
54
|
0
|
|
|
|
|
0
|
$state = 0; |
55
|
0
|
|
|
|
|
0
|
$n++; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif ( ($state == 3) && ($c eq ']') ) { |
58
|
7
|
|
|
|
|
18
|
$l[$ix++] = substr($s,$j,$i-$j+1); |
59
|
7
|
|
|
|
|
12
|
$j = $i+1; |
60
|
7
|
|
|
|
|
7
|
$state = 0; |
61
|
7
|
|
|
|
|
9
|
$n = 0; |
62
|
|
|
|
|
|
|
} |
63
|
205
|
|
|
|
|
243
|
$i++; |
64
|
|
|
|
|
|
|
} |
65
|
19
|
|
|
|
|
69
|
$l[$ix++] = substr($s,$j,$i-$j); |
66
|
|
|
|
|
|
|
|
67
|
19
|
|
|
|
|
94
|
return @l; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |