… | |
… | |
56 | |
56 | |
57 | our $DIED = sub { warn "$@" }; |
57 | our $DIED = sub { warn "$@" }; |
58 | |
58 | |
59 | =item scope_guard BLOCK |
59 | =item scope_guard BLOCK |
60 | |
60 | |
|
|
61 | =item scope_guard ($coderef) |
|
|
62 | |
61 | Registers a block that is executed when the current scope (block, |
63 | Registers a block that is executed when the current scope (block, |
62 | function, method, eval etc.) is exited. |
64 | function, method, eval etc.) is exited. |
63 | |
65 | |
64 | See the EXCEPTIONS section for an explanation of how exceptions |
66 | See the EXCEPTIONS section for an explanation of how exceptions |
65 | (i.e. C<die>) are handled inside guard blocks. |
67 | (i.e. C<die>) are handled inside guard blocks. |
… | |
… | |
102 | |
104 | |
103 | # do something with the new timezone |
105 | # do something with the new timezone |
104 | } |
106 | } |
105 | |
107 | |
106 | =item my $guard = guard BLOCK |
108 | =item my $guard = guard BLOCK |
|
|
109 | |
|
|
110 | =item my $guard = guard ($coderef) |
107 | |
111 | |
108 | Behaves the same as C<scope_guard>, except that instead of executing |
112 | Behaves the same as C<scope_guard>, except that instead of executing |
109 | the block on scope exit, it returns an object whose lifetime determines |
113 | the block on scope exit, it returns an object whose lifetime determines |
110 | when the BLOCK gets executed: when the last reference to the object gets |
114 | when the BLOCK gets executed: when the last reference to the object gets |
111 | destroyed, the BLOCK gets executed as with C<scope_guard>. |
115 | destroyed, the BLOCK gets executed as with C<scope_guard>. |