[TxMt] auto HTML table snippet
Paul McCann
paul.mccann at adelaide.edu.au
Sat Mar 10 08:59:39 UTC 2007
Hi again,
Please excuse my old eyes: I got excited by all the symmetry I
thought I saw in the table, and missed the fact that the first row is
special. So one-liner becomes two-liner... ah well... To get the
following table output
> <table>
> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr>
> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr>
> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr>
> </table>
use the previous prescription, but with the command:
#!/usr/bin/perl
chomp($first=<>);print "<table>\n\t<tr><th>",join("</th><th>",(split(/
\t/,$first))),"</th></tr>\n\t<tr><td>";
print join("</td></tr>\n\t<tr><td>",map {chomp;join("</td><td>",(split
(/\t/,$_)))} <>),"</td></tr>\n</table>\n";
Cheers,
Paul
More information about the textmate
mailing list