$y = 123; sub f { print("$y\n"); } # 456 or 123 { local $y = 456; f(); } # Same var, localized f(); # same var, global __END__ 456 123