Created
October 23, 2012 11:35
-
-
Save phluks/3938301 to your computer and use it in GitHub Desktop.
Perl AnyEvent: How to make async calls in a loop - oh, this seems to work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use AnyEvent; | |
use AnyEvent::Util qw"run_cmd"; | |
sub f { | |
my($x) = @_; | |
warn "got (($x))\n"; | |
}; | |
for my $n (1..10) { | |
my $rand = int(rand(10)); | |
$run = run_cmd "sleep $rand; echo $n", ">", \&f; | |
#$run->recv; | |
} | |
$run->recv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment