in reply to Re: Input to external program
in thread Handling long command lines (was: Input to external program)

Thanks for the help...I couldn't get it to work ;-(
(As a reminder, I am on Win32...)

open (THING, '|-', 'sort.exe'); my @unsorted = qw(bbb aaa ccc eee ddd); print THING "$_ " foreach @unsorted; close (THING); # My assumption is that after I close(), sort.exe knows to start "sort +ing"...
outputs:
bbb aaa ccc eee ddd

Replies are listed 'Best First'.
Re: Win32: best way to Input to external program
by choocroot (Friar) on May 11, 2002 at 09:41 UTC
    I know that the unix "sort" work on lines so perhaps you might need to replace :
    print THING "$_ " foreach @unsorted;
    by
    print THING "$_\n" foreach @unsorted;

    ???

    "sort" reads all the lines and sort them in memory (and using temporary files), then when it receive an EOF on STDIN (your close()) it print out the sorted lines.

      aahh, this is why I like asking questions here...ya always learn something new ;-)