Spreadsheet-HTML
view release on metacpan or search on metacpan
bin/benchmark-spreadsheet-html view on Meta::CPAN
sub brute_force {
my $str = '';
$str .= "<table>\n";
for (@$data) {
$str .= " <tr>\n";
for (@$_) {
$str .= " <td>$_</td>\n";
}
$str .= " </tr>\n";
}
$str .= "</table>\n";
return $str;
}
sub cgi {
my $q = CGI->new;
$q->table( $q->Tr([ map $q->td( $_ ), @$data ]) );
}
sub template {
my $tmpl = '<table>[% FOREACH row = rows %]
<tr>[% FOREACH cell = row %]
<td>[% cell %]</td>[% END %]
</tr>[% END %]
</table>
';
my $table = Template->new;
my $out = '';
$table->process( \$tmpl, { rows => $data }, \$out ) or warn $table->error, $/;
}
sub html_template {
my $tmpl = q(<table><tmpl_loop rows>
<tr><tmpl_loop row>
<td><tmpl_var cell></td></tmpl_loop>
</tr></tmpl_loop>
</table>
);
my $table = HTML::Template->new( scalarref => \$tmpl, die_on_bad_params => 0 );
$table->param( rows => [ map { row => [ map { cell => $_ }, @$_ ] }, @$data ] );
$table->output;
}
sub html_table {
my $table = new HTML::Table( $data );
$table->getTable;
}
sub html_element {
my $table = HTML::Element->new_from_lol( [table => map [tr => map [td => $_ ], @$_ ], @$data ]);
$table->as_HTML;
}
sub html_tiny {
my $h = HTML::Tiny->new;
$h->table( [ map $h->tr( [ map $h->td( $_ ), @$_ ] ), @$data ]);
}
sub html_autotag {
my $auto = HTML::AutoTag->new;
$auto->tag( tag => 'table', cdata => [ map { tag => 'tr', cdata => [ map { tag => 'td', cdata => $_, }, @$_ ], }, @$data ] );
}
sub dbix_xhtml_table {
my $table = DBIx::XHTML_Table->new( $data );
$table->output;
}
sub html_fromarrayref {
HTML::FromArrayref::HTML( [ table => {}, map [ tr => {}, map [ td => $_ ], @$_ ], @$data ] );
}
sub data_table {
my $t = Data::Table->new( $data, $header, 0 );
$t->html;
}
sub html_tabulate {
my $t = HTML::Tabulate->new;
$t->render( $data);
}
sub spreadsheet_html {
my $table = Spreadsheet::HTML->new( data => $data );
$table->generate;
}
sub self_only {
my $method = shift;
my $table = Spreadsheet::HTML->new( @_ );
$table->$method;
}
__END__
=head1 NAME
benchmark-spreadsheet-html - HTML table generator benchmarks.
=head1 SYNOPSIS
benchmark-spreadsheet-html
Options:
--modules benchmark only these modules
--size number of rows and columns in table
--count number of times to run benchmarks
--only-self test various configurations on distro only
--help list usage
--man print man page
=head1 OPTIONS
=over 8
=item B<--modules>
Benchmark only these modules.
benchmark-spreadsheet-html --module Template --module HTML::Template
( run in 0.603 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )