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

you know, that is pretty much exactly what i was thinking, and i tested a method like that locally on my pc.. *with nice results*

the only problem is with how i did it in testing, which was a continuous while loop, this increased my cpu usage from 3-5% to 60%.
but i figure this has to do with the loop right? also im on windows testing before i move to the shell. *dont wanna make the provider angry lol*

Replies are listed 'Best First'.
Re^7: timer without modules
by Random_Walk (Prior) on Nov 10, 2009 at 14:26 UTC

    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!