in reply to Module to limit email floods?
Wrap the sub that sends the alerts in a sub that records and checks for the last time that particular alert was sent, and have it do nothing if it was already sent within some specified period:
use constant INTERVAL => 3600; my %alerts; sub wrapSendSMS{ my( $alert, $no ) = @_; ## Do nothing if we've sent one recently return if exists $alerts{ $alert } and time() - $alerts{ $alert } < INTERVAL; ## Send it and record when sendSMS( $alert, $no ); $alerts{ $alert } = time; return 1; }
|
---|