On Wed, 05 Dec 2007 18:57:51 -0500, Venks wrote:

> What's the best way to capture STDOUT into an Array? I looked at popen3,
> open4, systemu but couldn't figure out how to do this.
> 
> In short, I want to execute a system call like "ls -l" and capture it
> into an array. Of course, "ls -l" may not have proper delimiter but
> assume that the delimiter is TAB or COMMA.
> 
> Thanks,

You can use the IO objects returned by popen3 in any way that you'd use a 
normal file. To get an array of lines, one string per line, use 
#readlines. To parse it as a CSV, for example, the csv library in ruby 
should work with CSV.parse

--Ken

-- 
Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/