以下は、crontabで実行するスクリプトに使用しているperlコードです
if($enable_family_members==0)
{
  my $sql="select name from test where testid IN (". join(',',  @set) . ')';
  my $sth = $dbh->prepare($sql);
  $sth->execute or die "SQL Error: $DBI::errstr\n"; 
}
while (my ($name)=$sth->fetchrow_array())
{
  print "name: $name";
}  
このスクリプトを実行しようとすると、エラーが発生しますCan't call method "fetchrow_array" on an undefined value at line 9。our $sth でキーワードの代わりにmy キーワードを使用しようとすると、エラーが発生しません。このエラーを解決する正しい方法は何ですか。