Aspect::Guard - General purpose guard object for destroy-time actions
SCOPE: { my $guard = Aspect::Guard->new( sub { print "Goodbye World!\n"; } ); } # Prints here as it exits the scope
The Aspect::Guard class shipping with Aspect is a convenience module for creating CODE based objects that execute when they fall out of scope.
CODE
It's usage is effectively summarised by the synopsis.
my $guard = Aspect::Guard->new( sub { do_something(); } );
The new method creates a new guard object. It takes a single CODE references as a parameter, which it will bless into the guard class, which will execute the code reference when it's DESTROY hook is called.
new
DESTROY
Adam Kennedy <adamk@cpan.org>
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.
To install Aspect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Aspect
CPAN shell
perl -MCPAN -e shell install Aspect
For more information on module installation, please visit the detailed CPAN module installation guide.