From: Jagadeesh Date: 2010-01-11T15:30:06+09:00 Subject: Re: Help Thanks Jeff. yes you are correct. But have a question On Jan 11, 11:04 am, Jeff Peng wrote: > 14:25 +0900,Jagadeesh: > > > DATA = {} > > prs = [ > > 457678,457678-3,open > > 457678,457678-5,closed > > 457678,457678-6,open > > ] > > > prs.each do |line| > >     (pr, pr_scope, state) = line.split(/,/) > >     DATA[pr] = Hash[state, pr_scope] > > end > > What you wanted is maybe: > > ~/tmp$ cat hash.rb > prs = [ > "457678,457678-3,open", > "457678,457678-5,closed", > "457678,457678-6,open", > ] > > data = Hash.new do |h,k| h[k] = [] end I added something like y = lambda { |h,k| h[k] = Hash.new(&y) } $DATA = Hash.new(&y) But I do not understood why to add y = lambda { |h,k| h[k] = Hash.new(&y) } Please explain. I am newbie to Ruby and coming from Perl.