#!/usr/bin/perl use strict; use warnings; use v5.10; use AnyEvent; use AnyEvent::Util; # OBS: This doesn't work! for my $n (1..100) { my $rand = int(rand(10)); my $hdl; $hdl = AnyEvent::io ( fh => \*STDIN, poll => 'r', cb => sub { my $str = `sleep $rand; echo $n`; output($str); } ); } # Hmm - args sub output { my $n = shift; say "Got: $n"; } __END__ perl testAny.pl illegal file descriptor or filehandle (either no attached file descriptor or illegal value): at /usr/local/lib64/perl5/AnyEvent/Impl/EV.pm line 55.