<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set(obj, glob, value, separator="/", afilter=None):
 """ Given a path glob, set all existing elements in the document to the given value. Returns the number of elements changed. """

    changed = 0
    globlist = __safe_path__(glob, separator)
    for path in _inner_search(obj, globlist, separator):
        changed += 1
        dpath.path.set(obj, path, value, create_missing=False, afilter=afilter)
    return changed