NAME

Math::ModInt::Event::Trap - catching events triggered by Math::ModInt

VERSION

This documentation refers to version 0.001 of Math::ModInt::Event::Trap.

SYNOPSIS

# event consumer interface:

use Math::ModInt::Event::Trap;

sub my_handler {
    my ($event) = @_;
    # ... insert code here ...
    return 0;            # call no handler after this one
    return 1;            # continue calling subsequent handlers
}

$trap = Math::ModInt::Event::Trap->new($event, \&my_handler);
$trap = Math::ModInt::Event::Trap->new($event, 'ignore');
$trap = Math::ModInt::Event::Trap->new($event, 'warn');
$trap = Math::ModInt::Event::Trap->new($event, 'die');

undef $trap;              # discard this trap

Math::ModInt::Event::Trap->new($event, \&my_handler);
Math::ModInt::Event::Trap->new($event, 'ignore');
Math::ModInt::Event::Trap->new($event, 'warn');
Math::ModInt::Event::Trap->new($event, 'die');

# event producer interface:

Math::ModInt::Event::Trap->broadcast($event);

DESCRIPTION

This module is closely related to Math::ModInt::Event and should in general not be directly accessed from application code. Please refer to Math::ModInt::Event for a more user-friendly description of both module's functionalities.

Class Methods

new

Constructor, takes an event object, and a handler coderef or a generic handler name. Returns the new trap object.

broadcast

Notifies active event handlers of an event. Takes an event, returns the number of handlers called.

EXPORT

Math::ModInt::Event::Trap has no exports.

DIAGNOSTICS

Standard warning handlers print "warning: " and the short description of the event (like "undefined result") on stderr, followed by a caller source code location.

Standard error handlers die with "error: " and the short description of the event (like "undefined result").

SEE ALSO

AUTHOR

Martin Becker, <becker-cpan-mp@cozap.com>

LICENSE AND COPYRIGHT

Copyright (c) 2010 by Martin Becker. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.0 or, at your option, any later version of Perl 5 you may have available.

DISCLAIMER OF WARRANTY

This library is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.