Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Package level scope callbacks.

by mvc (Scribe)
on Aug 01, 2004 at 08:26 UTC ( #379030=note: print w/replies, xml ) Need Help??


in reply to Package level scope callbacks.

When you talk about package scope, do you mean you want to listen to specific call flows?

If so, then Joost is right, and this is a job for Aspect . Version 0.10 will be out today.

Here is how to print foo each time Employee::calc_* is called, but only if Company::calc_salaries exists in the call flow. So if the call flow is Test::test_employee ... Employee::calc_salary, then it will not be printed:

use Aspect; before { print 'foo' } call qr/^Employee::calc_/ & cflow company => 'Company::calc_salaries';

There is also the Listenable aspect (Aspect-0.10), for a full implementation of Observer. But because you have pointcuts, you can fire events only in some call flow. Which you cannot do with normal Observer.

Replies are listed 'Best First'.
Re^2: Package level scope callbacks.
by gaal (Parson) on Aug 01, 2004 at 12:31 UTC
    Shouldn't that be & instead of && because of overloading and stuff?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://379030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-05-14 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (148 votes). Check out past polls.

    Notices?