line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Sudoku::Component::Controller::Loader;
|
2
|
|
|
|
|
|
|
{
|
3
|
3
|
|
|
3
|
|
36374
|
use strict;
|
|
3
|
|
|
|
|
83
|
|
|
3
|
|
|
|
|
110
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
87
|
|
5
|
3
|
|
|
3
|
|
16
|
use Carp;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
303
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
779
|
use Games::Sudoku::Component::Table::Item;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1477
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub load {
|
12
|
2
|
|
|
2
|
1
|
1309
|
my $pkg = shift;
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
5
|
my $str;
|
15
|
|
|
|
|
|
|
|
16
|
2
|
50
|
33
|
|
|
23
|
if (@_ == 1 and !ref $_[0]) {
|
|
|
0
|
0
|
|
|
|
|
17
|
2
|
|
|
|
|
6
|
$str = shift;
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
elsif (@_ == 1 and ref $_[0] eq 'SCALAR') {
|
20
|
0
|
|
|
|
|
0
|
$str = ${ $_[0] };
|
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
else {
|
23
|
0
|
0
|
|
|
|
0
|
my %options = ref $_[0] ? %{ $_[0] } : @_;
|
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
0
|
|
|
0
|
if (my $file = $options{filename} || $options{file}) {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
$str = $pkg->_load_from_file($file);
|
27
|
|
|
|
|
|
|
}
|
28
|
|
|
|
|
|
|
elsif ($options{scalar}) {
|
29
|
0
|
|
|
|
|
0
|
$str = $options{scalar};
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
elsif ($options{scalarref}) {
|
32
|
0
|
|
|
|
|
0
|
$str = ${ $options{scalarref} };
|
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
2
|
|
50
|
|
|
9
|
$str ||= '';
|
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
5
|
my @cells = ();
|
39
|
2
|
|
|
|
|
4
|
my ($row, $col) = (0,0);
|
40
|
2
|
|
|
|
|
18
|
foreach my $line (split(/\n+/, $str)) {
|
41
|
9
|
|
|
|
|
19
|
$line =~ s/\r//g;
|
42
|
9
|
|
|
|
|
10
|
$row++;
|
43
|
9
|
|
|
|
|
12
|
$col = 0;
|
44
|
9
|
|
|
|
|
26
|
foreach my $value (split(/\s+/, $line)) {
|
45
|
45
|
|
|
|
|
51
|
$col++;
|
46
|
45
|
50
|
|
|
|
170
|
$value = 0 unless $value =~ /^[0-9]+$/;
|
47
|
45
|
|
|
|
|
201
|
push @cells, Games::Sudoku::Component::Table::Item->new(
|
48
|
|
|
|
|
|
|
row => $row,
|
49
|
|
|
|
|
|
|
col => $col,
|
50
|
|
|
|
|
|
|
allowed => [],
|
51
|
|
|
|
|
|
|
value => $value,
|
52
|
|
|
|
|
|
|
);
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
}
|
55
|
2
|
|
|
|
|
17
|
@cells;
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _load_from_file {
|
59
|
0
|
|
|
0
|
|
|
my ($pkg, $file) = @_;
|
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
open my $fh, '<', $file or croak "failed to open $file: $!";
|
62
|
0
|
|
|
|
|
|
read $fh, my $str, (-s $file);
|
63
|
0
|
|
|
|
|
|
close $fh;
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$str;
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1;
|
70
|
|
|
|
|
|
|
__END__
|