This has nothing to do with your question, but I thought I'd add it. It's regarding the coding of your sql queries. I use heredocs. It's not really necessary for a short query, but comes in handy for complex ones. Makes code very easy to follow.
my $sql = <<EOQ;
id = 218'