From: Venks Date: 2007-12-06T09:38:35+09:00 Subject: Re: Capturing STDOUT from a system call (POSIX) into an array Thanks for your quick reply. I realize that you don't even need to use split. What I am missing is how to create a 2 dimensional array with each line contents in an array assuming that they are separated by a COMMA. Let me be more specific. Assume that we have a file under /tmp/test.txt with the following contents. aaa, 10, test1 bbb, 20, test2 ccc, 30, test3 ddd, 40, test4 I want to create a 2 dimensional array with each line being an array. lines = `cat /tmp/test.txt` will create a single dimensional array by default. Thanks, On Dec 5, 2007 7:14 PM, Phrogz wrote: > > On Dec 5, 4:57 pm, 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. > > lines = `ls -l`.split( /\n/ ) > >