SYNOPSIS

  SCOPE: {

      my $guard = Aspect::Guard->new( sub {
          print "Goodbye World!\n";
      } );

  }
  # Prints here as it exits the scope

DESCRIPTION

The Aspect::Guard class shipping with Aspect is a convenience module for creating \*(C`CODE\*(C' based objects that execute when they fall out of scope.

It's usage is effectively summarised by the synopsis.

METHODS

new

my $guard = Aspect::Guard->new( sub { do_something(); } );

The \*(C`new\*(C' method creates a new guard object. It takes a single \*(C`CODE\*(C' references as a parameter, which it will bless into the guard class, which will execute the code reference when it's \*(C`DESTROY\*(C' hook is called.

AUTHOR

Adam Kennedy <[email protected]>

COPYRIGHT

Copyright 2011 - 2013 Adam Kennedy.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.