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.
In reply to Re^7: timer without modules
by Random_Walk
in thread timer without modules
by elunatic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |