--- Guard/Guard.pm 2008/12/13 22:05:20 1.14 +++ Guard/Guard.pm 2009/07/19 05:44:10 1.21 @@ -12,9 +12,14 @@ scope_guard { chdir "/" }; chdir "/etc"; - call_function_that_might_die_or_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 + =head1 DESCRIPTION This module implements so-called "guards". A guard is something (usually @@ -39,7 +44,7 @@ no warnings; BEGIN { - $VERSION = '0.5'; + $VERSION = '1.021'; @ISA = qw(Exporter); @EXPORT = qw(guard scope_guard); @@ -191,5 +196,14 @@ Thanks to Marco Maisenhelder, who reminded me of the C<$Guard::DIED> solution to the problem of exceptions. +=head1 SEE ALSO + +L and L, which actually implement +dynamic, not scoped guards, and have a lot higher CPU, memory and typing +overhead. + +L, which has apparently never been finished and corrupts +memory when used. + =cut