save_pwd(sub { ... })

Save the current directory and assure that outside the block the old directory will still be valid.