From: Adlai Date: 2009-05-21T05:15:02+09:00 Subject: require not working correctly? I'm just starting out in Ruby, and I used the one-click installer. The version on my computer seems to be Ruby 1.8.6-27. I'm working through some of the examples in Why's Poignant Guide, and things seem to have broken down here: File wordlist.rb contains: puts 'Wordlist got required' code_words = { 'starmonkeys' => 'Phil and Pete, those prickly chancellors of the New Reich', 'catapult' => 'chucky go-go', 'firebomb' => 'Heat-Assisted Living', 'Nigeria' => "Ny and Jerry's Dry Cleaning (with Donuts)", 'Put the kabosh on' => 'Put the cable box on' } File script.rb contains: require 'wordlist' # Get evil idea and swap in code words puts "Enter your new idea: " idea = gets code_words.each do |real, code| idea.gsub!(real, code) end # Save the jibberish to a new file puts "File encoded. Please enter a name for this idea: " idea_name = gets.strip File::open("idea-" + idea_name + ".txt", "w") do |f| f << idea end This is basically copied out of the Poignant Guide, with the addition of the puts method at the start of wordlist.rb. Both are in the same directory. I navigate to that directory in cmd, and then type ruby script.rb It prints Wordlist got required, then prompts for an evil idea, and after I hit enter, gives the following error: script.rb:5: undefined local variable or method `code_words' for main:Object (NameError) What am I doing wrong? Thanks, - Adlai