line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Table::Compiler; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
779
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
1637
|
use HTML::Table; |
|
1
|
|
|
|
|
32216
|
|
|
1
|
|
|
|
|
83
|
|
5
|
1
|
|
|
1
|
|
26
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use vars qw( @ISA $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
370
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw( HTML::Table ); |
10
|
|
|
|
|
|
|
$VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub compile { |
14
|
1
|
|
|
1
|
1
|
1295
|
my ($self, $data) = @_; |
15
|
|
|
|
|
|
|
|
16
|
1
|
50
|
33
|
|
|
18
|
unless ( defined($data) && ref $data && (ref $data eq 'ARRAY') ) { |
|
|
|
33
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
croak "build(): usage error"; |
18
|
|
|
|
|
|
|
} |
19
|
1
|
50
|
|
|
|
12
|
my $cols_number = $self->getTableCols() or die "no table cols"; |
20
|
1
|
50
|
|
|
|
14
|
my $rows_number = $self->getTableRows() or die "no table rows"; |
21
|
|
|
|
|
|
|
|
22
|
1
|
50
|
33
|
|
|
37
|
if ( ($rows_number * $cols_number < @$data) && $self->{autogrow} ) { |
23
|
1
|
|
|
|
|
3
|
my $splits = @$data / $cols_number; |
24
|
1
|
50
|
|
|
|
6
|
$rows_number = (int ($splits) == $splits) ? $splits : $splits + 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
2
|
my @table = (); |
28
|
1
|
|
|
|
|
8
|
for ( my $i=1; $i <= $rows_number; $i++ ) { |
29
|
4
|
|
|
|
|
5
|
my @row = (); |
30
|
4
|
|
|
|
|
14
|
for ( my $j=1; $j <= $cols_number; $j++ ) { |
31
|
12
|
|
|
|
|
254
|
push @row, $data->[ (($i-1) * $cols_number) + $j - 1 ]; |
32
|
12
|
|
|
|
|
38
|
$self->setCell($i, $j, $row[-1]); |
33
|
|
|
|
|
|
|
} |
34
|
4
|
|
|
|
|
116
|
push @table, [@row]; |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
4
|
return \@table; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
__END__ |