$condvar = AnyEvent->condvar; for (1..$multiLimit) { doProcess(); } $condvar->recv; #### $condvar->begin; say "Active ${aval}, Offset ${oval}"; ### This was originally another sub, but I brought it inline for debug my $content; my $fh = FileHandle->new; if ($debug) { say "Reading ${localfile} offset ${offset} for length ${contentLength}";} $fh->open("< $localfile"); binmode($fh); read($fh,$content,$contentLength,$offset); if ($debug) { say "readData read ".byteSize($content);} $fh->close; ### http_request "PUT" => $url, headers=>$headerVals, body=>$content, sub { my ($body, $hdr) = @_; say "received, Size: ", length $body; say $body; $activeCount--; $condvar->end; doProcess(); }; return 1 #### Active:1, Offset:0 Reading test offset 0 for length 4194303 readData read 4194303 Active:2, Offset:4194304 Reading test offset 4194304 for length 4194303 readData read 8388607 Active:3, Offset:8388608 Reading test offset 8388608 for length 4194303 readData read 12582911