I used this method excpet I modified it slightly. I changed
if ($response eq 'SQLEND') {
to
if ($response =~ "SQLEND") {
That seemes to clear up the infinite loop it produced. I assumed that it was due to a CR-LF at the end and tried cleaning it up with chomp but it didn't help. So in the interest of getting this project wrapped up I just searched for the SQLEND.
Thanks for the help!