I’ve been using WordPress.com for almost two months. I decided to use WordPress.com rather than the complete WordPress software in order to keep the focus on writing, rather than tweaking with software. WordPress.com is limited, but those limits have a certain benefit if you can learn to live with them.
I ran into one case where WordPress.com as it exists today is too limited. My tweak-geek side got the best of me, of course, and the end result expanded beyond my initial goals. But, the end result works well enough. You can see an example of how I used it on the books page, above.
The problem I was running into was the pain of pasting lists of data into a post or page. You might want to do this if you had a spreadsheet, or database query. If you were using a self-hosted or one-click install of WordPress, you would add some more plugins, or hack the code to bring in some data.
I just wanted a relatively long list of information displayed as a HTML table, or maybe as an HTML list. This is classic text processing: convert a CSV file to HTML. Nothing complicated, and when I think of text processing, I think of Perl. So I wrote a simple Perl script to do this.
My script basically takes the following CSV info:
Tom Sawyer, Mark Twain
The Maltese Falcon, Dashell Hammett
And transforms it into:
<table border="0"> <thead> <tr> <th>Title</th> <th>Author</th> </tr> </thead> <tbody> <tr> <td>Tom Sawyer</td> <td>MarkTwain</td> </tr> <tr> <td>The Maltese Falcon</td> <td>Dashell Hammett</td> </tr> ...etc...</tbody> </table>
While I’ve programmed for a long time in a number of different languages, I’m somewhat new to Perl. I’m sure that the Perl experts reading this would find a simpler way to do what I am doing, but it works for me.
There really is nothing special about this that makes it only for WordPress, of course. You could really use it for any CSV to HTML conversion task. But, for me, I’d rather have a simple tool that just does one thing right, especially if I write it myself.
If anyone reading this is interested in the Perl code, I’ll be happy to send it you. On the other hand, if check out CPAN and you will find a host of resources to build a better tool yourself.