From: Jan Svitok Date: 2006-10-28T19:47:04+09:00 Subject: Re: how to import variable from other .rb file? On 10/28/06, camenix wrote: > Hello all, > I have two file : > > config.rb: > tool_mysql='X:/mysql.exe' > > main.rb : > require "config.rb" > puts tool_mysql > > It didn't work.for main.rb can not import variable from config.rb > > Is there any mothod to do this without parsing config.rb? > > Is here anyone who can help me? 1. eval File.read('config.rb') 3. use constants: TOOL_MYSQL = 'dsfsdffds' puts TOOL_MYSQL 2. use global variables: config.rb : $tool_mysql = 'cxxx' puts $tool_mysql 3. use YAML for configuration: config.yaml: tool_mysql: cxdsfsdf require 'yaml' config = YAML.load_file('config.yaml') puts config['tool_mysql']