Guard is a Perl module implementing so-called "guards," which are things that "guard" a resource, ensuring that it is safely cleaned up when expected, even if exceptional conditions interrupt the normal control flow. This allows one to write code which executes an arbitrary code block or subroutine when either the related Guard Object is destroyed or when the current scope ends. In other languages, this sort of functionality is provided by the 'finally' keyword.