```{index} single: scope_guard (Guard) ``` ```{index} single: Guard::scope_guard ``` # scope_guard `scope_guard BLOCK`: run BLOCK when the enclosing scope is left - at its end, by `return`, `last`/`next`, or an exception passing through. Several in one scope run in reverse order of creation. Exported by default. ```perl { my $lock = acquire(); scope_guard { release($lock) }; work(); # release runs even if this dies } ```