NAME
Aspect::Advice::After - Execute code after a function is called
SYNOPSIS
use Aspect;
after {
# Trace all returning calls to your module
print STDERR "Called my function " . $_->sub_name . "\n";
# Suppress exceptions AND alter the results to foo()
if ( $_->short_sub_name eq 'foo' ) {
$_->return_value(1) if $_->exception;
$_->return_value( $_->return_value + 1 );
}
} call qr/^ MyModule::\w+ $/
DESCRIPTION
The after
advice type is used to execute code after a function is called, regardless of whether or not the function returned normally or returned an exception.
The after
advice type should be used when you need to potentially make multiple different changes to the returned value or the thrown exception.
If you only care about normally returned values you should use after_returning
(Aspect::Advice::AfterReturning) instead.
If you only care about handling exceptions you should use after_throwing
(Aspect::Advice::AfterThrowing) instead.
AUTHORS
Adam Kennedy <adamk@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2010 Adam Kennedy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.