On Mon, Nov 30, 2009 at 10:45 AM, David Schmidt <zivildie...@gmail.com> wrote: > Hello > > I would like to execute some Code after a certain amount of time has > passed (then restart the timer but with a different time value) > I looked at IO::Async::Timer::Countdown but this timer only gets > started when used with a IO::Async::Loop. > > Basically I am looking for something as simple as > > my $do_it = { ... }; > use MyTimer; > my timer = MyTimer->new($delay, $do_it); > > and inside of $do_it I intend to start another timer. > > is there any simple class that does what I want? I failed to find it. > > thanks in advance > > david >
Hi David, I'm not really clear on what you're trying to do, here: looking at IO::Async seems to indicate that you want your program to continue while waiting for the timer, but your sample code would seem to pause while the timer elapses. If you *don't* want to block for the timer, the normal idom would be: eval { local $SIG{ALRM} = { # usually dies }; alarm $timeout; # do something here until timeout }; if ($@) { #check $@ to make sure alarm died, not something else } Either way, you should be able to use the built-in functions to accomplish your task. See the docs for sleep(), alarm(), and select() for more info. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/