sub LookupServerID { my $serverName = shift; my $sql = "select server_id from server_tbl where server_name = '$serverName'" # run the sql through your $perms_db and return the id # you'll probably want to cache these values later... }