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.
|
|---|