For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > May 2004 > Delimited Text to HTML Table









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Delimited Text to HTML Table
JR

2004-05-19, 1:30 pm

Hi. I've searched to no avail through CPAN for a module that can
convert a delimited block of text into an HTML table, and then modify
cell, row, and column attributes. I probably simply overlooked it by
using the incorrect search parameters on CPAN. I'm guessing that
there must be a module out there that can do something such as this.
The HTML::Table module appears to be a good module, and I guess I
could always loop through my text block in my main script, and then
use this module to specify specific attributes for each cell. I'd
rather, though, be able to pass the entire text block as part of an
object attribute, and then simply call specific methods within a
module to act on the object (I hope I explained this reasonably well,
and I hope I'm not misunderstanding how HTML::Table really works). For
example, I'd like to be able to do something such as this:

--------------------------------------------------------------
#!/perl -w
use strict;
use diagnostics;

my @data = qw(
Column 1|Column 2|Column 3
Row 2-1|Row 2-2|Row 2-3
Row 3-1|Row 3-2|Row 3-3
Row 4-1|Row 4-2|Row 4-3
);

my %attrs = (
file => ['D:\perl\test.html', '>'],
delimiter => '|',
padnulls => 0,
default_fill => undef,
alternate => undef,
alternate_start => undef,
alternate_colors => undef,
alternate_stop => undef,
table => [@table],
attrs_dir => 'D:\perl',
type => 'td'
...
...
...
);

my $html = Transform->new(%attrs);

$html->setCell(position => [3,1],
bgcolor => 'magenta',
new_data => undef);

$html->setRow(row => 3,
bgcolor => 'white',
new_data => ["new cell1|new cell2|new cell3"]);
--------------------------------------------------------------

Does anyone know of such a module?

Thanks very much.

JR
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com