From: Jan Svitok Date: 2006-11-10T07:46:00+09:00 Subject: Re: Spliting a line and passing the results On 11/9/06, Sean Hussey wrote: > Actually, let me step back. This is really good, but what if I wanted > named parameters instead? Or is there a way to split a line and load > it into a hash and pass that? > > The file doesn't have header information, but I know what the order of > the fields will be. I guess I could just write a method, pass the > line to it for parsing, and return a hash. Would that be about right? KEYS = %w[ name id phone color temperature dog password ] data = line.chomp.split(...) hash = Hash[*(KEYS.zip(data))]