NAME

Aspect::Advice - change how Perl code is run at a pointcut

SYNOPSIS

# creating using public interface: trace calls to Account subs
use Aspect;
before { print 'called: '. shift->sub_name } call qw/^Account::/;

# creating using internal interface
use Aspect::Advice;
$advice = Aspect::Advice->new(before =>
   { print 'called: '. shift->sub_name },
   call qw/^Account::/
);

DESCRIPTION

An advice is composed of a pointcut and some code that will run at the pointcut. The code is run before or after the pointcut, depending on advice type.

You do not normally create advice using the constructor. By use()ing Aspect, you get 2 subs imported: before() and after(), that do what you need. They also store the advice if called in void context, so you do not need to keep in scope. The advice code will be removed when the advice object is destroyed.

The advice code is given one parameter: an Aspect::AdviceContext. You use this object to change the parameter list for the matched sub, modify return value, find out information about the matched sub, and more.

This class has no public methods that do anything, but there are accessors weaver(), type(), code(), and pointcut(), if you need them.

SEE ALSO

See the Aspect pod for a guide to the Aspect module.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

AVAILABILITY

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.

AUTHORS

Marcel Grünauer, <marcel@cpan.org>

Ran Eilam <eilara@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2001 by Marcel Grünauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.