From: Jeremy Bopp Date: 2013-01-12T00:01:17+09:00 Subject: Re: How Ruby environment varibles work in realtime program? On 01/11/2013 08:14 AM, Arup Rakshit wrote: > Joel Pearson wrote in post #1091923: >> I should think >> [DLN_LIBRARY_PATH, HOME, LOGDIR, RUBYOPT, RUBYSHELL].each {|var| puts >> var } >> would suffice to check them all whenever you want. > > I am getting the below error: > > > Microsoft Windows XP [Version 5.1.2600] > (C) Copyright 1985-2001 Microsoft Corp. > > C:\Documents and Settings\rakshit>irb > irb(main):001:0> [DIN_LIBRARY_PATH,HOME,LOGDIR,RUBYOPT,RUBYSHELL].each > {|var|put > s var } > NameError: uninitialized constant DIN_LIBRARY_PATH > from (irb):1 > irb(main):002:0> [DLN_LIBRARY_PATH,HOME,LOGDIR,RUBYOPT,RUBYSHELL].each > {|var|put > s var } > NameError: uninitialized constant DLN_LIBRARY_PATH > from (irb):2 As you can see, Ruby thinks those names you specified are constants, but you need them to be strings in this case. You also need to look up their values via the ENV hash: %w(DIN_LIBRARY_PATH HOME LOGDIR RUBYOPT RUBYSHELL).each do |var| puts "#{var}=#{ENV[var]}" end The %w above takes a string defined between the parenthesis and splits it on whitespace. The result is an array of strings that we then iterate over. Then we print the variable name and the value of that variable from the environment via the ENV hash. -Jeremy