--- Guard/README 2008/12/26 13:04:04 1.4 +++ Guard/README 2009/07/19 05:44:10 1.5 @@ -3,16 +3,21 @@ SYNOPSIS use Guard; - - # temporarily chdir to "/etc" directory, but make sure + + # temporarily chdir to "/etc" directory, but make sure # to go back to "/" no matter how myfun exits: sub myfun { scope_guard { chdir "/" }; chdir "/etc"; - - code_that_might_die_or_does_other_fun_stuff; + + code_that_might_die_or_does_other_fun_stuff; } + # create an object that, when the last reference to it is gone, + # invokes the given codeblock: + my $guard = guard { print "destroyed!\n" }; + undef $guard; # probably destroyed here + DESCRIPTION This module implements so-called "guards". A guard is something (usually an object) that "guards" a resource, ensuring that it is cleaned up when