I am trying to figure out Event Loops in Perl?
Currently my program does something like this:
while(my $event = wait_for_event()){
handle_event($event);
try_to_do_something();
}
where wait_for_event is blocking.
I am trying to figure out if I can use EV, or AnyEvent(AE), or something else to add another event watcher.
for example, I want to be able to call try_to_do_something() every 2 seconds, but am currently stuck putting it into the event loop.
Also, I would like to add some form of interaction with the program, possibly through sockets(another watcher).
Thanks
Maybe you are trying to do something like this?
This snippet with AnyEvent and AnyEvent::Filesys::Notify is just one way to do it. Basically it’s almost always the same way, regardless of your framework: Setup your watchers with your callbacks and enter your “mainloop”.