On Wed, Dec 15, 1999 at 09:11:53AM -0800, [EMAIL PROTECTED] wrote:
> Not quite. It didn't work the first time, so I tried calling the at()
> method directly. Viz:
>
> $w = Event->timer(after => 1);
>
> $w->cb(sub {
> $now = Event::time();
> $next = $now + rand(20.);
> print "Now: ", scalar localtime($now), " Next: ", scalar localtime($next), "\n";
> $w->at($next);
> $w->again;
> });
> loop();
>
> The output looks like:
>
> [jsalmon@gw]$ ./ev.pl
> Now: Wed Dec 15 09:04:02 1999 Next: Wed Dec 15 09:04:12 1999
> Now: Wed Dec 15 09:04:04 1999 Next: Wed Dec 15 09:04:23 1999
> Now: Wed Dec 15 09:04:06 1999 Next: Wed Dec 15 09:04:12 1999
> Now: Wed Dec 15 09:04:08 1999 Next: Wed Dec 15 09:04:19 1999
Hm hm hm... That's what I get for not testing. Try this:
use Event qw(loop);
$w = Event->timer(interval => 1);
$w->cb(sub {
$now = Event::time();
$next = rand(20.);
print "Now: ", scalar localtime($now), " Next: ", $next, "\n";
$w->interval($next);
});
loop();
--
"Never ascribe to malice that which can be explained by stupidity."
via, but not speaking for Deutsche Bank