I know it doesn't work.
I just think it is a good example, if the code can be fixed. I have done this once already, when I first saw this example on the net. Then it proved to be a very valuable learning resource for me.
I needed this knowledge again today, so I've google'd it up.
I decided to post it here so that others can learn from it. I know it's not Perl, but I remember reading here somewhere that about 5% of the posts can be off-topic, and, it's possible to use MySQL from Perl, so I believe it can be useful to at least a few people on this site.