From: Paul Brannan Date: 2003-04-02T03:00:54+09:00 Subject: Re: eval'ing a config file On Wed, Apr 02, 2003 at 02:15:15AM +0900, Ian Macdonald wrote: > LDAP_HOST = foo.bar.com > LDAP_PORT = 389 > LDAP_PASS = foobar Change this to: LDAP_HOST = 'foo.bar.com' LDAP_PORT = 389 LDAP_PASS = 'foobar' > File.open("/etc/ldaprc") do |f| > f.each do |line| > next if line =~ /^(#|$)/ > var, val = /^(.+?)\s*=\s*(.+)$/.match(line)[1,2] > eval "#{var} = '#{val}'" > end > end Change this to: require '/etc/ldaprc' It's not the best solution for everything, but it's about as simple as roading a configuration file can get! Paul