Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Re: Help: How to process output of a program
October 15, 2008, 6:06 pm
rate this thread
Based on my test, I'd say it doesn't work on Win32, or at least not
warn open2 my $in, my $out, q;
print $out qq foreach (1..100);
close $out or die;
print while (<$in>);
This works on Linux, but hangs on Windows. It hangs at the while (<$in>).
Since sort needs to read all input before generating any output,
deadlock should not be an issue. It also leaves sort.exe hanging around.
(I actually starting using "cat"/"type", using the >& to redirect to
another filehandle to avoid deadlocks, but I couldn't figure out how to
make Window's "type" read from its stdin. So I switched to sort. Then
once using sort, I realized I no longer needed >& so simplified it. None
of these steps worked on windows).
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)
Copyright 1987-2006, Larry Wall
Binary build 817  provided by ActiveState
http://www.ActiveState.com Built Mar 20 2006 17:54:25
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
Re: Help: How to process output of a program
Interesting. I've honestly not tried this on Win32. I've been
privileged enough to _not_ have to use Windows for many, many years.
Maybe I'll install ActiveState's Perl on a Windows laptop and run some
tests (but I probably won't). I appreciate the follow up.
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!