sub table {
# $tab is again a number.
# Everything else is optional.
my ($tab,$opt) = @_;
my @attributes;
push @attributes, qq(id="$opt->{id}") if $opt->{id};
push @attributes, qq(class="$opt->{class}") if $opt->{class};
push @attributes, qq(style="$opt->{style}") if $opt->{style};
my $format = @attributes > 0 ? ' '.join(' ',@attributes) : '';
my $tag = 'table'.$format;
line($tab,qq(<$tag>));
# If a caption is wanted set caption => "Caption"
line($tab + 1,qq(
$opt->{caption})) if $opt->{caption};
# Set headings to the same array ref as you would if you were setting the row.
row($tab + 1,'header',$opt->{headings}) if $opt->{headings};
# In most tables, the data rows would come next. For this array ref
# you would push all the array refs you would use for row above.
# (I hope that makes sense.)
if ($opt->{data}) {
row($tab + 1,'data',$_) for @{$opt->{data}};
}
# In most tables, there could be final rows which contain totals.
# For this array ref you would push all the array refs you would
# use for row above. Some tables have a header row and rows with
# their own headings.
# (I hope that makes sense.)
if ($opt->{whead}) {
row($tab + 1,'whead',$_) for @{$opt->{whead}};
}
line($tab,q());
}