in reply to Re: Re: Re: Re: Re: HTML and CGI coding
in thread HTML and CGI coding
use strict; use CGI qw(header); use HTML::Template; my $cart_ref = { 42 => { qty => 5, price => 5, description => 'widget 42', }, 77 => { qty => 2, price => 7, description => 'widget 77', }, }; my $html = do {local $/;<DATA>}; my $tmpl = HTML::Template->new(scalarref=> \$html); my $rows = [ map { { id => $_, %{$cart_ref->{$_}} } } keys %$cart_ref ]; $tmpl->param(rows => $rows); print header, $tmpl->output; __DATA__ <table> <tr> <th>Item</th> <th>Quantity</th> <th>Description</th> <th>Price</th> </tr> <tmpl_loop rows> <tr> <td><tmpl_var id></td> <td><tmpl_var qty></td> <td><tmpl_var description></td> <td><tmpl_var price></td> </tr> </tmpl_loop> </table>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|