in reply to do something no more than 3 times a second

Well, you cannot sleep for half a second using the standard sleep function; you'd need the sleep from Time::HiRes. I would only sleep if there's an actual need to sleep. Perhaps something like:
sub do_request { use Time::HiRes qw[sleep time]; use 5.010; state $sleep = [0, 0, 0]; my $url = shift; while ($$sleep[0] + 1 > time) { # Loop, as sleep() may get interrupted. sleep time - $$sleep[0] + 1; } $sleep = [@$sleep [1 .. $#$sleep], time]; ... fetch from server ... }

Replies are listed 'Best First'.
Re^2: do something no more than 3 times a second
by BrimBorium (Friar) on Nov 26, 2010 at 20:22 UTC

    you could use select as described in perlfunc

    You can effect a sleep of 250 milliseconds this way: select(undef, undef, undef, 0.25);
      Sure, but select() isn't the standard sleep either. And you still need to figure out what the fourth argument should be - select() isn't going to tell you that.