in reply to Passing database handles

you need to add a line like the following to the end of the function:
$sth->finish();

$ perl -e 'do() || ! do() ;' Undefined subroutine &main::try