sub my_restornator { local %ENV; %ENV = restore_env(); # do things with the restored CGI object # goes back the way it was after this brace: }