in reply to Can I auto-save and restore global variables?
You can use local, though that only works for individual variables, not an entire package:
$Data::Dumper::blah = 0; say $Data::Dumper::blah; # 0 { local $Data::Dumper::blah = 1; say $Data::Dumper::blah; # 1 } say $Data::Dumper::blah; # 0
The nice thing about local variables is that they're dynamically-scoped, so if you invoke subroutines from that block, they will also see the localized value.
|
|---|