in reply to Trouble with poll code

You can't simply insert SQL into a perl script and hope that it will work by some magic.

Use DBI to interact with your database.