sub getsqlvalue { my ($dbh,$sqlstatement)= @_; my $sth = $dbh->prepare($sqlstatement) $sth->execute || die "MySQL execute failed"; my $rows = $sth->fetchall_arrayref; $sth->finish(); return ( ref( $rows ) eq 'ARRAY' and @$rows ) ? $$rows[0][0] : undef; }