On Nov 18, 2008, at 6:51 AM, Bil Kleb wrote:

> Hi,
>
> I'm grabbing the owner and file names from `find . -perm -g+r -ls`
> which has ls -dgils output like,
>
>  6744065        8 -rw-r--r--    1 kleb     users          289 Nov 30
> 2007 Ruby/README
>
> with something like,
>
>  find_result.each_line do |line|
>    fields = line.split
>    user_name, file_name = fields[4], fields.last
>
> I've also played with,
>
>  _,_,_,_,user,_,_,_,_,_,file = a.split
>
> But both leave me thinking there is a better way without resorting
> to a regex?

given that you have an array, and fields, you could use arrayfields ;-)


a = Array.fields %w( size foo mode bar user group )

find_result.each_line do |line|
   a.replace line.split

   p a['user']
end


a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama