Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- a) FINALLY not called in case of exception
- -- its fine with one variable though it separates variable declaration, its initialization, and its finally block
- my $foo;
- try {
- $foo = init ...;
- }
- catch {
- die ..;
- }
- FINALLY { $foo->destroy }
- -- b) FINALLY not called in case return
- -- to solve this finally must be specified before try block (therefor with check)
- my $foo;
- FINALLY { $foo->destroy if $foo }
- try {
- $foo = init ...;
- return if ...;
- }
- catch {
- die ..;
- }
- -- c) two coupled variables
- my $foo;
- FINALLY { $foo->destroy if $foo }
- my $bar;
- FINALLY { $foo->unregistry ($bar) and $bar->destroy if $bar && $foo }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement