<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def genrepl(scope):
 """Replacement function with specific scope."""


    def repl(match):
        """Internal replacement function."""

        name = match.group('name')

        value = lookup(name, scope=scope)

        result = name.replace('.', '_')
        scope[result] = value

        return result

    return repl