$y = 123; sub f { print("$y\n"); } # 456 { local $y = 456; f(); } # Same var