tags:

views:

145

answers:

3

I have an application in Perl that reads in HTML based mark up and converts it to a textual output. One of the things I have encountered is the need to easily convert a HTML table to a fixed font output.

 <table border="1">
 <tr><td>Hello</td>
     <td>World</td>
 <tr>
     <td>foo</td>
     <td>bar</td>
 </tr></table>

I am looking for something that can take the above table and create something like the following.

 ------------------------------
 | Hello     | World          |
 ------------------------------
 | foo       | bar            |
 ------------------------------

I know how to approach this in Perl and write the process, but I am hoping that there is some library out there that already will do this for me.

A: 

Lynx is your friend.

mouviciel
+6  A: 

I've used Text::Table with great success. In combination with something like HTML::TreeBuilder it should be pretty easy.

friedo
A: 

If available, I would use an external program like lynx, links or w3m. I don't know if any of them can handle arbitrary HTML thrown at them, though.

Joe Casadonte