Aspect...::After(3pm)
β¨ NAME β¨
Aspect::Advice::After β bestie, this one runs your code after a function gets 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_name eq 'foo' ) {
if ( $_->exception ) {
$_->return_value(1);
} else {
$_->return_value( $_->return_value + 1 );
}
}
} call qr/^ MyModule::\w+ $/
π DESCRIPTION π
Okay so the after advice type is the one you reach for when you wanna run some code after a function is called β and the way that it does not care whether that function returned all normally or just fully threw an exception?? iconic. it handles both, no cap. π₯
You want after specifically when you need to potentially make multiple different changes to the returned value or the thrown exception β like, more than one thing going on, bestie.
If you only care about normally returned values, then use returning in the pointcut, because that excludes join points occurring due to exceptions. β¨
And if you only care about handling exceptions, use throwing in the pointcut, which excludes join points occurring due to normal return. πΈ
π AUTHORS π
Adam Kennedy <adamk@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright 2010 - 2013 Adam Kennedy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
k that's the whole page, mwah π«Ά this was documented by the lovely folks behind perl v5.36.0, dated 2023-07-02, and yes the page is literally titled Aspect...::After(3pm) β go off, filename π
π¦ where this page comes from
- debian trixie: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms