It appears that the script ldbtest.pl is being run by your
shell instead of by the perl interpreter.

Do you have the shebang line (#!/usr/bin/perl -w
or something like it)
as the first line of your script? Also check the permissions
on this script. I assume they are ok, considering you are
able to run it from command line, but doesn't hurt to check.