debian man page for aspect::advice::before

Query: aspect::advice::before

OS: debian

Section: 3pm

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

Aspect::Advice::Before(3pm)				User Contributed Perl Documentation			       Aspect::Advice::Before(3pm)

NAME
Aspect::Advice::Before - Execute code before a function is called
SYNOPSIS
use Aspect; before { # Trace all calls to your module print STDERR "Called my function " . $_->sub_name . " "; # Shortcut calls to foo() to always be true if ( $_->short_name eq 'foo' ) { return $_->return_value(1); } # Add an extra flag to bar() but call as normal if ( $_->short_name eq 'bar' ) { $_->args( $_->args, 'flag' ); } } call qr/^ MyModule::w+ $/
DESCRIPTION
The "before" advice type is used to execute advice code prior to entry into a target function. It is implemented by Aspect::Advice::Before. As well as creating side effects that run before the main code, the "before" advice type is particularly useful for changing parameters or shortcutting calls to functions entirely and replacing the value they would normally return with a different value. Please note that the "highest" pointcut (Aspect::Pointcut::Highest) is incompatible with "before". Creating a "before" advice with a pointcut tree that contains a "highest" pointcut will result in an exception. If speed is important to your program then "before" is particular interesting as the "before" implementation is the only one that can take advantage of tail calls via Perl's "goto" function, where the rest of the advice types need the more costly Sub::Uplevel to keep caller() returning correctly.
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::Before(3pm)
Related Man Pages
aspect::advice(3pm) - debian
aspect::advice::after(3pm) - debian
aspect::advice::around(3pm) - debian
aspect::advice::before(3pm) - debian
aspect::library::singleton(3pm) - debian
Similar Topics in the Unix Linux Community
career Advice
Career advice: Solaris &amp; SUN support
Need to build a quick FTP server, Advice??
AIX Hardware Migration w/ HACMP...Advice Needed
Hobbyist looking for AIX 5.3 licensing advice...