in reply to DBI and like statment

I think the problem may just be that you're using double quotes in your assignment to $sql. This means it's going to try to evaluate the % symbol as the beginning to a hash value. You need to escape it with a backslash, methinks