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; }