Adds triggers for trigger point. You can have any number of triggers for each point. Each coderef will be passed a reference to the calling object, as well as arguments passed in via call_trigger. Return values will be captured in list context.

If add_trigger is called with named parameters and the abortable parameter is passed a true value, a false return value from trigger code will stop processing of this trigger point and return a false value to the calling code.

If add_trigger is called without the abortable flag, return values will be captured by call_trigger, but failures will be ignored.

If add_trigger is called as object method, whole current trigger table will be copied onto the object and the new trigger added to that. (The object must be implemented as hash.)

Calls triggers for trigger point, which were added via add_trigger method. Each triggers will be passed a copy of the object as the first argument. Remaining arguments passed to call_trigger will be passed on to each trigger. Triggers are invoked in the same order they were defined.

If there are no abortable triggers or no abortable trigger point returns a false value, call_trigger will return the number of triggers processed.

If an abortable trigger returns a false value, call trigger will stop execution of the trigger point and return undef.

Are you aware of the perl-aspects project and the Aspect module? Very similar to Class::Trigger by the look of it, but its not nearly as explicit. Its not necessary for foo() to actually say "triggers go *here*", you just add them.

I originally added code like this to Class::DBI to cope with one particular case: auto-upkeep of full-text search indices.

So I added functionality in Class::DBI to be able to trigger an arbitary subroutine every time something happened - then it was a simple matter of setting up triggers on INSERT and UPDATE to reindex that row, and on DELETE to remove that index row.