The variables $1, $2, $3 ... are automatically localized, and their scope extends to the end of the enclosing block or eval string, or to the next successful pattern match, whichever comes first.