how to convert shell captures into anyevent style?

Zsbán Ambrus ambrus at math.bme.hu
Fri Mar 30 21:29:05 CEST 2012


On 3/30/12, Fulko Hew <fulko.hew at gmail.com> wrote:
> I tried that (I thought correctly, as per below) and I get an error rather
> than my callback being called.
>
> Not a GLOB reference at /usr/lib/perl5/site_perl/5.8.8/AnyEvent/Util.pm
> line 592.

I cannot reproduce your error.  Look, this works fine for me.

$ perl -e 'use AnyEvent; use AnyEvent::Util qw"run_cmd"; sub f {
my($x) = @_; warn "got (($x))\n"; }; $run = run_cmd "echo hello; sleep
2; echo world", ">", \&f; $run->recv;'
got ((hello
))
got ((world
))
got (())
$

If this works for you, try to interpolate between the two to find what
breaks.  If a minimal example like this doesn't work for you, then I
don't know what the problem could be.

Try to make sure you're using the most recent version of the AnyEvent
module, which is version 5.14 now.  Also, what version of perl are you
using?  You might want to upgrade that too if it's too old.

One more thing.  If you want to debug the error by reading the source
code of AnyEvent::Util, don't forget that in an error message perl
often show the line number of the if condition if the error is in an
elseif condition later in that if-elseif statement.

Ambrus



More information about the anyevent mailing list