how to convert shell captures into anyevent style?

Fulko Hew fulko.hew at gmail.com
Thu Mar 29 18:42:20 CEST 2012


I'm having a disconnect in my (minimal) knowledge of Perl & AnyEvent style
of programming.

The problem I'm having is because my app is currently a mixture of
traditional Perl and AnyEvent, and its causing problems.

What I basically have is:

sub obtainer {
    foreach (`prog|prog|prog`) {
        ... do stuff...
    }
}

... more stuff ...

$obtainer = AnyEvent->timer(interval => $refresh_interval, cb =>
\&obtainer);
AnyEvent->condvar->wait;

The 'more stuff' contains 'legal' AnyEvent socket code.

Whats happening is that when obtainer() starts to run,
its doing so much for so long that the socket code I have
doesn't get a chance to run (in time) and then the networking
aspect of my application fails.

What I obviously need to do is to turn my obtainer() into an event driven
aspect too!  And I think what I want is an 'IO Watcher', but...

I don't know how to translate my `prog|prog` concept into the
filehandle concept that IO watcher talks about.

Any help or suggestions would be appreciate.

Fulko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20120329/96fb4d4d/attachment.html>


More information about the anyevent mailing list