HTML-Spry-DataSet
view release on metacpan or search on metacpan
lib/HTML/Spry/DataSet.pm view on Meta::CPAN
my $self = shift;
# Open the file
my $file = shift;
my $html = IO::File->new( $file, "w" );
unless ( defined $html ) {
Carp::croak("Failed to open '$file' for write");
}
# Write the file
$html->say('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
$html->say('<html>');
$html->say('<head>');
$html->say('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
$html->say('</head>');
$html->say('<body>');
foreach my $id ( sort keys %$self ) {
$html->say("<table id='$id'>");
foreach my $row ( @{ $self->{$id} } ) {
$html->say(' <tr>');
foreach my $cell ( @$row ) {
t/02_main.t view on Meta::CPAN
# Write out to the HTML file
ok( $dataset->write('dataset.html'), '->write returns ok' );
# Read the file back in
open( FILE, '<', 'dataset.html');
local $/ = undef;
my $buffer = <FILE>;
close FILE;
is_string( $buffer, <<'END_HTML', '->write creates the correct file' );
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table id='ds1'>
<tr>
<td>Rank</td>
<td>Dependencies</td>
<td>Author</td>
( run in 1.835 second using v1.01-cache-2.11-cpan-49f99fa48dc )