Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^7: timer without modules

by Random_Walk (Prior)
on Nov 10, 2009 at 14:26 UTC ( #806225=note: print w/replies, xml ) Need Help??


in reply to Re^6: timer without modules
in thread timer without modules

Just do the test and store the time when the user calls the function.

# code not tested use strict; use warnings; my %called; my $interval = 60; # how long before they can call it again sub something { my $user = shift; # pass the function the name of the user calling + it my $now = time; return if exists $called{$user} and $now < $called{$user} + $inter +val; $called{user} = $now; # do the costly funtion }

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://806225]
help
Chatterbox?
LanX atheism is so boring logical...
1nickt loves the two additional downvotes for Re^2: Catalyst:: Dispatcher - usage of expand_actions, lol
[LanX]: your v welcome
[LanX]: I'm curious, what's the problem with this sig?

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-05-24 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?