title: ruby 1.8.7 undefined local variable
body: <p>I have two files:</p>
  
  <pre><code># wordlist.rb
  code_words = {
      'computer' =&gt; 'devil worshipping device',
      'penny' =&gt; 'pretty',
      'decoration' =&gt; 'girlandes, green light bulbs, skeletons',
      'pets' =&gt; 'captured souls'
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code># confidant.rb
  require 'wordlist'
  
  # Get string and swap in code words
  print 'Say your piece: 
  '
  
  idea = gets
  code_words.each do |original, translated|
      idea.gsub! original, translated
  end
  
  # Save the translated idea to a new file
  print 'File encoded. Please enter a name for your piece: 
  '
  
  piece_name = gets.strip
  File::open 'piece-' + piece_name + '.txt', 'w' do |f|
      f &lt;&lt; idea
  end
  </code></pre>
  
  <p>running ruby confidant.rb results in an error message: </p>
  
  <blockquote>
    <p>confidant.rb:12: undefined local variable or method 'code_words' for
    main:Object (NameError)</p>
  </blockquote>
  
  <p>Do I have to qualify code_words somehow? The code is a slightly adapted example from _why's poignant guide.</p>