From: Massimiliano Mirra Date: 2002-09-30T06:57:58+09:00 Subject: Re: How to load vars from users' app.conf (quite long) On Sun, Sep 29, 2002 at 11:11:53PM +0900, gabriele renzi 1: clear, long, unpretty > 2: shameless ripped from rbot/config.rb > 3: shorter, but using eval > 4: huge case , kind of > 5: quicky and risky: 6: With a singleton instead of globals. # comment var1=foo var2=bar # comment require 'singleton' module App class Config def initialize @fields = {} File.open("app.conf") do |f| f.read.scan(/^(\w+)=(\w+)$/).each do |name, value| @fields[name] = value end end end def [](name) @fields[name] end end CONF = Config.instance end require 'app/config' p App::CONF['var1'] p App::CONF['var2'] You'll probably want to improve the regex passed to #scan in Config#initialize. HTH Massimiliano