# autodie::Scope::Guard - man - phpman

## NAME
    [autodie::Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuard/markdown) - Wrapper class for calling subs at end of scope

## SYNOPSIS
        use [autodie::Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuard/markdown);
        $^H{'my-key'} = [autodie::Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuard/markdown)->new(sub {
            print "Hallo world\n";
        });

## DESCRIPTION
    This class is used to bless perl subs so that they are invoked when they are destroyed. This is
    mostly useful for ensuring the code is invoked at end of scope. This module is not a part of
    autodie's public API.

    This module is directly inspired by chocolateboy's excellent [Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/Scope%3A%3AGuard/markdown) module.

### Methods
   new
      my $hook = [autodie::Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuard/markdown)->new(sub {});

    Creates a new "[autodie::Scope::Guard](https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuard/markdown)", which will invoke the given sub once it goes out of scope
    (i.e. its DESTROY handler is called).

## AUTHOR
    Copyright 2008-2009, Paul Fenwick <<pjf@perltraining.com.au>>

## LICENSE
    This module is free software. You may distribute it under the same terms as Perl itself.

