sub LookupServerID { # get the servername that was passed into the function my $serverName = shift; # build the sql to select the server_id my $sql = "select server_id from server_tbl where server_name = '$serverName'" # execute the sql with the open $perms_db object if ($perms_db->Sql($sql)) { # error during sql! print "Error:" . $perms_db->Error() . "\n"; # return a value anyway and let the caller check for -1 return -1; } # process the result set $perms_db->FetchRow(); # get the first row within the result set my(%data) = $perms_db->DataHash(); # return the server_id to the caller return $data{'server_id'}; # PLEASE NOTE: this code does not watch out for the case where the server_name does not exist. you should code for this case. }