foreach my $seq (0..$number-1) { my $doneflag = \$play_done[$seq]; $$doneflag = 0; $play_list[$seq] = threads->create(\&PlayoutThread, $doneflag, $target_list[$seq], $media_type, $portnum, $playouts); # Mark as already done if thread creation failed unless ($play_list[$seq]) { $$doneflag = 2; $play_errors++; } # Count it if thread creation succeeded else { $started++; } }