… | |
… | |
42 | package Guard; |
42 | package Guard; |
43 | |
43 | |
44 | no warnings; |
44 | no warnings; |
45 | |
45 | |
46 | BEGIN { |
46 | BEGIN { |
47 | $VERSION = '1.021'; |
47 | $VERSION = 1.023; |
48 | @ISA = qw(Exporter); |
48 | @ISA = qw(Exporter); |
49 | @EXPORT = qw(guard scope_guard); |
49 | @EXPORT = qw(guard scope_guard); |
50 | |
50 | |
51 | require Exporter; |
51 | require Exporter; |
52 | |
52 | |
… | |
… | |
84 | BLOCK calls C<exit>, C<goto>, C<last> or escapes via other means. |
84 | BLOCK calls C<exit>, C<goto>, C<last> or escapes via other means. |
85 | |
85 | |
86 | If multiple BLOCKs are registered to the same scope, they will be executed |
86 | If multiple BLOCKs are registered to the same scope, they will be executed |
87 | in reverse order. Other scope-related things such as C<local> are managed |
87 | in reverse order. Other scope-related things such as C<local> are managed |
88 | via the same mechanism, so variables C<local>ised I<after> calling |
88 | via the same mechanism, so variables C<local>ised I<after> calling |
89 | C<scope_guard> will be restored when the guard runs. |
89 | C<scope_guard> will be restored I<before> the guard runs. |
90 | |
90 | |
91 | Example: temporarily change the timezone for the current process, |
91 | Example: temporarily change the timezone for the current process, |
92 | ensuring it will be reset when the C<if> scope is exited: |
92 | ensuring it will be reset when the C<if> scope is exited: |
93 | |
93 | |
94 | use Guard; |
94 | use Guard; |
… | |
… | |
197 | solution to the problem of exceptions. |
197 | solution to the problem of exceptions. |
198 | |
198 | |
199 | =head1 SEE ALSO |
199 | =head1 SEE ALSO |
200 | |
200 | |
201 | L<Scope::Guard> and L<Sub::ScopeFinalizer>, which actually implement |
201 | L<Scope::Guard> and L<Sub::ScopeFinalizer>, which actually implement |
202 | dynamic guards only, not scoped guards, and have a lot higher CPU, memory |
202 | dynamically scoped guards only, not the lexically scoped guards that their |
203 | and typing overhead. |
203 | documentation promises, and have a lot higher CPU, memory and typing |
|
|
204 | overhead. |
204 | |
205 | |
205 | L<Hook::Scope>, which has apparently never been finished and can corrupt |
206 | L<Hook::Scope>, which has apparently never been finished and can corrupt |
206 | memory when used. |
207 | memory when used. |
207 | |
208 | |
|
|
209 | L<Scope::Guard> seems to have a big SEE ALSO section for even more |
|
|
210 | modules like it. |
|
|
211 | |
208 | =cut |
212 | =cut |
209 | |
213 | |