line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /bin/false |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (C) 2021 Guido Flohr , |
4
|
|
|
|
|
|
|
# all rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This program is free software. It comes without any warranty, to |
7
|
|
|
|
|
|
|
# the extent permitted by applicable law. You can redistribute it |
8
|
|
|
|
|
|
|
# and/or modify it under the terms of the Do What the Fuck You Want |
9
|
|
|
|
|
|
|
# to Public License, Version 2, as published by Sam Hocevar. See |
10
|
|
|
|
|
|
|
# http://www.wtfpl.net/ for more details. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Chess::Plisco::EPD; |
13
|
|
|
|
|
|
|
$Chess::Plisco::EPD::VERSION = '0.4'; |
14
|
5
|
|
|
5
|
|
279670
|
use strict; |
|
5
|
|
|
|
|
49
|
|
|
5
|
|
|
|
|
136
|
|
15
|
5
|
|
|
5
|
|
1733
|
use integer; |
|
5
|
|
|
|
|
52
|
|
|
5
|
|
|
|
|
24
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
163
|
use Scalar::Util qw(reftype); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
212
|
|
18
|
5
|
|
|
5
|
|
1858
|
use Locale::TextDomain qw('Chess-Plisco'); |
|
5
|
|
|
|
|
66079
|
|
|
5
|
|
|
|
|
34
|
|
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
5
|
|
109359
|
use Chess::Plisco::EPD::Record; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
1968
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
8
|
|
|
8
|
0
|
10088
|
my ($class, $arg, $filename) = @_; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
100
|
|
|
67
|
my $reftype = (reftype $arg) || ''; |
26
|
8
|
|
|
|
|
15
|
my @lines; |
27
|
8
|
100
|
|
|
|
66
|
if ('SCALAR' eq $reftype) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3021
|
@lines = split /\n/, $$arg; |
29
|
1
|
|
|
|
|
11
|
$filename = __"[in-memory string]"; |
30
|
|
|
|
|
|
|
} elsif ('ARRAY' eq $reftype) { |
31
|
1
|
|
|
|
|
2000
|
@lines = @$arg; |
32
|
1
|
|
|
|
|
9
|
$filename = __"[in-memory array]"; |
33
|
|
|
|
|
|
|
} elsif ('GLOB' eq $reftype) { |
34
|
1
|
|
|
|
|
5874
|
@lines = <$arg>; |
35
|
1
|
|
33
|
|
|
41
|
$filename ||= __"[file-handle]"; |
36
|
|
|
|
|
|
|
} else { |
37
|
5
|
100
|
|
|
|
2964
|
open my $fh, '<', $arg |
38
|
|
|
|
|
|
|
or die __x("cannot open '{filename}' for reading: {error}!\n", |
39
|
|
|
|
|
|
|
filename => $arg, |
40
|
|
|
|
|
|
|
error => $!); |
41
|
4
|
|
33
|
|
|
37
|
$filename ||= $arg; |
42
|
4
|
|
|
|
|
30129
|
@lines = <$fh>; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
7
|
|
|
|
|
353
|
my $lineno = 0; |
46
|
7
|
|
|
|
|
21
|
my $ws = "[ \011-\015]"; |
47
|
7
|
|
|
|
|
15
|
my @self; |
48
|
7
|
|
|
|
|
21
|
foreach my $line (@lines) { |
49
|
70000
|
|
|
|
|
83310
|
++$lineno; |
50
|
70000
|
|
|
|
|
288645
|
$line =~ s/^$ws+//; |
51
|
70000
|
|
|
|
|
140212
|
$line =~ s/ws+$//; |
52
|
70000
|
50
|
|
|
|
130988
|
next if !length $line; |
53
|
|
|
|
|
|
|
|
54
|
70000
|
|
|
|
|
94117
|
my $record = eval { Chess::Plisco::EPD::Record->new($line) }; |
|
70000
|
|
|
|
|
196567
|
|
55
|
70000
|
50
|
|
|
|
149778
|
if ($@) { |
56
|
0
|
|
|
|
|
0
|
die "$filename:$lineno: $@"; |
57
|
|
|
|
|
|
|
} |
58
|
70000
|
|
|
|
|
163358
|
push @self, $record; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
7
|
|
|
|
|
103951
|
bless \@self, $class; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub __readFromFileHandle { |
65
|
0
|
|
|
0
|
|
0
|
my ($class, $filename, $fh) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
return <$fh>; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub records { |
71
|
11
|
|
|
11
|
0
|
6595
|
my ($self) = @_; |
72
|
|
|
|
|
|
|
|
73
|
11
|
|
|
|
|
10168
|
return @$self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |