if ($rec_ref->{'company'} ne "") { %ref = %$rec_ref; $found = 1; } $dbh->disconnect(); if ($found) { return %rec; } else { return undef; }