.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Aspect::Advice 3pm" .TH Aspect::Advice 3pm "2023-07-02" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Aspect::Advice \- Change how Perl code is run at a pointcut .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # Trace calls to all functions in all MyAccount classes \& use Aspect; \& \& before { \& print \*(AqCalled: \*(Aq. $_\->sub_name; \& } call qw/^MyAccount::/; \& \& \& \& # Repeat using the pure object\-oriented interface \& use Aspect::Advice::Before (); \& use Aspect::Pointcut::Call (); \& \& my $advice = Aspect::Advice::Before\->new( \& pointcut => Aspect::Pointcut::Call\->new( qr/^MyAccount::/ ), \& code => sub { \& print \*(Aqcalled: \*(Aq. $_\->sub_name; \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" An \*(L"advice\*(R" in \s-1AOP\s0 lingo is composed of a condition (known as a Aspect::Pointcut) and some code that will run when that pointcut is true. .PP This code is run before, after, or around the target pointcut depending on the particular advice type declaration used. .PP You do not normally create advice using the constructor. By \f(CW\*(C`use()\*(C'\fRing Aspect, you get five advice declaration subroutines imported. .PP \&\f(CW\*(C`before\*(C'\fR is used to indicate code that should run prior to the function being called. See Aspect::Advice::Before for more information. .PP \&\f(CW\*(C`after\*(C'\fR is used to indicate code that should run following the function being called, regardless of whether it returns normally or throws an exception. See Aspect::Advice::After for more information. .PP \&\f(CW\*(C`around\*(C'\fR is used to take deeper control of the call and gives you your own lexical scope between the caller and callee, with a specific \f(CW\*(C`proceed\*(C'\fR call required in your code to execute the target function. See Aspect::Advice::Around for more information. .PP When the advice code is called, it is provided with an Advice::Point object which describes the context of the call to the target function, and allows you to change it. .PP This parameter is provided both via the topic variable \f(CW$_\fR (since version 0.90) and additionally as the first parameter to the advice code (which may be deprecated at some point in the future). .PP If you are creating \f(CW\*(C`advice\*(C'\fR objects directly via the \s-1OO\s0 interface, you should never use this class directly but instead use the class of the particular type of advice you want to create. .SH "AUTHORS" .IX Header "AUTHORS" Adam Kennedy .PP Marcel GrĂ¼nauer .PP Ran Eilam .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2001 by Marcel GrĂ¼nauer .PP Some parts copyright 2009 \- 2013 Adam Kennedy. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.