2 |
|
|
3 |
sub table { |
sub table { |
4 |
my $cols = shift; |
my $cols = shift; |
5 |
|
my $th; |
6 |
|
|
7 |
|
if ( $cols < 0 ) { |
8 |
|
$cols = abs($cols); |
9 |
|
$th .= qq|<th>| . shift(@_) . qq|</td>| foreach ( 1 .. $cols ); |
10 |
|
$th .= qq|</tr>\n<tr>|; |
11 |
|
} |
12 |
|
|
13 |
my @td = map { "<td>$_</td>" } @_; |
my @td = map { "<td>$_</td>" } @_; |
14 |
my $html = qq{<table>\n<tr>}; |
my $html = qq{<table>\n<tr>$th}; |
15 |
foreach ( 0 .. $#td ) { |
foreach ( 0 .. $#td ) { |
16 |
$html .= $td[$_]; |
$html .= $td[$_]; |
17 |
$html .= qq{</tr>\n<tr>} if $_ % $cols == 1; |
$html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0; |
18 |
} |
} |
19 |
$html .= qq{</tr>\n</table>}; |
$html .= qq{</tr>\n</table>}; |
20 |
} |
} |