=for comment Here we retain Juerd's nice readable curly-brace syntax, and we also allow for reusable code (by assigning to global output string) allow for paramaterized tags (by using array ref with prm_table) allow for multiple-nested tags of any nesting-depth =cut ### INIT ### ---------------------------------------------- use strict; use warnings; ### INIT vars; global output string buffer; params for the parent +table; my $out; my $set_prm_table = [qw(red 1 100%)]; sub prm_table (&@){ my $st = $_[1] || ""; $out .= "<table bgcolor='$st->[0]' border='$st->[1]' width='$s +t->[2]'>"; $_[0]->(); $out .= "</table>"; } sub row (&) { $out .= "\n<tr>"; shift->(); $out .= "</tr>"; } sub cell (&) { $out .= "\n<td>"; shift->(); $out .= "</td>";} ### DISPLAY OUTPUT ### ---------------------------------------------- prm_table { for (1 .. 3){ row { cell {$out .= "foo $_"} } } }$set_prm_table; print $out; print "\n---------------------------\n";
In reply to Readable HTML tables (revisited) by dimar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |