Have you tried 'dbish' - "interactive command shell for Perl DBI"?
update: As for the not a code reference bit. it is because of the $db->("$query5b") where which you probably mean $db->prepare("$query5b"); or $db->do("$query5b"); instead.
-enlil
Comment on Re: win32::odbc & SQL from command line