On Monday, 25 November 2002 at 11:02:41 +0900, Damon wrote: > Ross Shaw <rshaw1961 / yahoo.com.au> wrote in message news:<rshaw1961-> Robert Cowham <rc / vaccaperna.co.uk> wrote: > > > > > What's the best ruby idiom for the following Perl: > > > > > > open(EMAIL, "<$EMAIL_FILE") or die "Failed to open $EMAIL_FILE"; > > > my %hash = map {chomp; split /\=/} (<EMAIL>); > > > close (EMAIL); > > > > > > (the above reads a file containing text like > > > > > > key1=value1 > > > key2=value2 > > > > > > into a hash. > > > > > h = {} > > File.foreach("fred.ini") do |line| > > key, value = line.chomp.split("=") > > h[key] = value > > end > > Would this be better if you changed split to: key, value = line.strip.split(/=/,2) That way, you could handle things like key1 = Fred = 2 #=> 'key1' => "Fred = 2" -- Jim Freeze ---------- Nothing is faster than the speed of light ... To prove this to yourself, try opening the refrigerator door before the light comes on.