Unix and Linux Discussions Tagged with advice |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
4 |
15,272 |
AIX |
|
|
|
2 |
1,988 |
Programming |
|
|
|
2 |
2,665 |
What is on Your Mind? |
|
|
|
1 |
2,091 |
What is on Your Mind? |
|
|
|
2 |
2,809 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
1,654 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,169 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
5,441 |
UNIX for Advanced & Expert Users |
|
|
|
36 |
124,942 |
IP Networking |
|
|
|
2 |
2,223 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
8,941 |
Shell Programming and Scripting |
|
|
|
2 |
3,241 |
Shell Programming and Scripting |
|
|
|
4 |
3,454 |
What is on Your Mind? |
|
|
|
2 |
3,589 |
Linux |
|
|
|
0 |
894 |
UNIX and Linux RSS News |
|
|
|
17 |
9,533 |
What is on Your Mind? |
|
|
|
14 |
4,850 |
Shell Programming and Scripting |
|
|
|
2 |
2,750 |
Red Hat |
|
|
|
3 |
2,199 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,121 |
Shell Programming and Scripting |
|
|
|
0 |
1,138 |
UNIX and Linux RSS News |
|
|
|
1 |
6,013 |
UNIX for Advanced & Expert Users |
|
|
|
6 |
3,368 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
31,158 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
3,551 |
IP Networking |
|
|
|
3 |
7,023 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
8,322 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,071 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
3,043 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,078 |
Cybersecurity |
|
|
|
2 |
5,485 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,899 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
4,268 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,074 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
37,002 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
5,574 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,788 |
IP Networking |
|
|
|
2 |
4,430 |
UNIX for Dummies Questions & Answers |
Aspect::Advice::Around(3pm) User Contributed Perl Documentation Aspect::Advice::Around(3pm)
NAME
Aspect::Advice::Around - Execute code both before and after a function
SYNOPSIS
use Aspect;
around {
# Trace all calls to your module
print STDERR "Called my function " . $_->sub_name . "
";
# Lexically alter a global for this function
local $MyModule::MAXSIZE = 1000;
# Continue and execute the function
$_->run_original;
# Suppress exceptions for the call
$_->return_value(1) if $_->exception;
} call qr/^ MyModule::w+ $/;
DESCRIPTION
The "around" advice type is used to execute code on either side of a function, allowing deep and precise control of how the function will
be called when none of the other advice types are good enough.
Using "around" advice is also critical if you want to lexically alter the environment in which the call will be made (as in the example
above where a global variable is temporarily changed).
This advice type is also the most computationally expensive to run, so if your problem can be solved with the use of a different advice
type, particularly "before", you should use that instead.
Please note that unlike the other advice types, your code in "around" is required to trigger the execution of the target function yourself
with the "proceed" method. If you do not "proceed" and also do not set either a "return_value" or "exception", the function call will
return "undef" in scalar context or the null list "()" in list context.
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.
perl v5.14.2 2012-02-01 Aspect::Advice::Around(3pm)