Created
October 28, 2011 21:24
-
-
Save barefootcoder/1323605 to your computer and use it in GitHub Desktop.
Demonstration of on_scope_end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package inner_pm; | |
BEGIN { warn "compiling inner pm" }; | |
use B::Hooks::EndOfScope; | |
sub inner_pm_func | |
{ | |
warn "entering inner pm sub"; | |
unless (0) | |
{ | |
on_scope_end sub { warn "on_scope_end hook called" }; | |
} | |
warn "leaving inner pm sub"; | |
} | |
warn "leaving inner pm compilation"; | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
BEGIN { warn "top of script" }; | |
use test_on_scope_end; | |
BEGIN { warn "pm loaded" }; | |
warn "normal runtime"; | |
END { warn "in END block" }; | |
BEGIN { warn "very end of compiling main script" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test_on_scope_end; | |
BEGIN { warn "compiling outer pm" }; | |
use inner_pm; | |
BEGIN { warn "loaded inner pm" }; | |
sub import | |
{ | |
warn "entering import"; | |
inner_pm::inner_pm_func(); | |
} | |
warn "leaving outer pm compilation"; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: