# man > B::Hooks::EndOfScope::XS

---
type: CommandReference
command: B::Hooks::EndOfScope::XS
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference

- `on_scope_end { ... }` — Execute code after the surrounding scope has been compiled
- `on_scope_end $code` — Same, with a code reference

This is the XS implementation of `B::Hooks::EndOfScope`, based on `Variable::Magic`. It will be automatically preferred if `Variable::Magic` is available. The function is exported by default; see `Sub::Exporter` to customize.

## Name

B::Hooks::EndOfScope::XS - Execute code after a scope finished compilation - XS implementation

## Synopsis

perl
use B::Hooks::EndOfScope::XS;
on_scope_end { ... };
on_scope_end $code;
## Options

None.

## Examples

perl
on_scope_end { ... };
on_scope_end $code;
## See Also

- [B::Hooks::EndOfScope](http://localhost/phpMan.php/perldoc/B%3A%3AHooks%3A%3AEndOfScope/markdown)
- [Variable::Magic](http://localhost/phpMan.php/perldoc/Variable%3A%3AMagic/markdown)
- [Sub::Exporter](http://localhost/phpMan.php/perldoc/Sub%3A%3AExporter/markdown)
- Bug tracker: [https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope](https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope)

## Exit Codes

Not documented.