[Thamesvalley-pm] generating HTML

ed ed-pm at s5h.net
Thu Oct 18 13:31:00 PDT 2007

On Thu, 18 Oct 2007 16:48:20 +0100
Greg Matthews <gmatt at nerc.ac.uk> wrote:

> Well... I threatened this email so here goes...
> Is there a neater way of generating html than this:
>      print INDEX "    <tr>
>        <td style=\"vertical-align: top;\">$host<br>
>        </td>\n";
> ??
> At the moment my code loops round generating table rows (of which the 
> above is the first column).
> Given that the table is of an arbitrary size (depending on the number
> of hosts defined) am I approaching this the right way? ie directly
> printing out the raw html?
> The generated page is essentially static, it is just generated by a
> cron job and the table contains links to pages of generated data for
> each host (if available).
> I'm used to making my perl look neat and readable but now that it 
> contains huge dollops of html (such as the definition of my $header
> and my $footer) it looks a mess.
> Let me know if anyone wants to see the whole thing (and have a good 
> laugh)...

As the others suggest, 

use templates;

but a simpler way might be to include a file from disk, and replace
bits using $var =~ s///g - if templates are too much work. I've not
personally been big on templates, but prefer to replace things in
files, just my way of being stuck in the mud I suppose.

The T1 to www.brokenmachine.com is rapping harder than Ice T because of
You have no chance to survive make your time. Tech Support is asleep.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/thamesvalley-pm/attachments/20071018/73e91425/attachment.bin 

More information about the Thamesvalley-pm mailing list