$n = 123; sub get_n { $n } BEGIN { delete $::{n} } $n = 456; print get_n(); print $n; #OUT 123456