I can see that being difficult, as I've read in a few places that pipe opens aren't supported in Perl threads.

Hm. Where? I've never heard of, nor encountered, any problems with piped-opens in threads. (unless its a *nix thing I've never seen reported.)

Try this which will happily run tens of concurrent piped-open commands on Windows:

#! perl -slw use strict; use threads; use Thread::Queue; our $T //= 10; our $N //= 1000; my $Q = new Thread::Queue; async{ my $tid = threads->tid; open my $cmd, '-|', 'count.pl ' . int( rand $N ) or die $!; $Q->enqueue( "$tid:$_" ) while defined ( $_ = <$cmd> ); $Q->enqueue( "$tid:done\n" ); $Q->enqueue( undef ); }->detach for 1 .. $T; for( 1 .. $T ) { while( $_ = $Q->dequeue ) { printf "%s", $_; } } __END__ ##This is count.pl #! perl -slw use strict; $|++; my $i = $ARGV[0] // 30; print --$i while $i and sleep 1;

Eg

C:\test>t-popen -T=10 -N=10 8:done 1:2 2:4 4:5 3:5 6:4 5:0 5:done 7:0 7:done 9:8 10:4 1:1 2:3 4:4 3:4 6:3 9:7 10:3 1:0 1:done 2:2 3:3 4:3 6:2 9:6 10:2 2:1 4:2 3:2 6:1 9:5 10:1 2:0 2:done 4:1 3:1 6:0 6:done 9:4 10:0 10:done 4:0 3:0 4:done 3:done 9:3 9:2 9:1 9:0 9:done

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Threads Printing Issue - Output Mangled / Term Crashing by BrowserUk
in thread Threads Printing Issue - Output Mangled / Term Crashing by bigbot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.