I mean, I like AnyEvent, but this can be done with core modules as well (albeit somewhat more verbose and error-prone...)