From: Ari Brown Date: 2007-07-03T16:07:52+09:00 Subject: LSRC Name Picker Hey all. I seem to get this error whenever I run my program. -----------------------------------------------------------| ERROR -----------------------------------------------------------| namePicker-cli.rb:58: syntax error, unexpected '{', expecting kEND @names { |f| lines = f.readlines ^ namePicker-cli.rb:60: syntax error, unexpected '}', expecting kEND -----------------------------------------------------------| What does this mean? Here is my code: -----------------------------------------------------------| CODE -----------------------------------------------------------| ########################################### # Tally ho, I'm going to write this # as best I can. Store the picked names # to a file, and then that will be the checker. ########################################### require 'ftools' require 'rubygems' require 'commandline/optionparser' include CommandLine ############################## # Set us up for CL options ############################## od = OptionParser.new { |o| o << Option.new(:flag, :names => %w[--help -h], :opt_description => "Prints this page." ) o << Option.new(:names => %w[--file -f], :arg_arity => [1,1], :arg_description => "file", :opt_found => OptionParser::GET_ARGS ) } op = od.parse ###################### # Set up some rules ###################### if op['--help'] puts od exit() end ################# # Variables... ################# FILE = op['--file'] ##################### # NamePicker Class ##################### class NamePicker def initialize # names = open(FILE) File.syscopy(FILE, '.names.txt') @names = open('.names.txt', 'w+') end def random selected = nil @names.inject { |choice, line| selected < 1/quiz.lineno.to_f ? line : choice } if selected puts selected.chomp @names { |f| lines = f.readlines ### LINE 58 lines.puts unless $. == selected.chomp } ### LINE 60 self.rewind end end end randomName = NamePicker.new randomName.random #end Suggestions? Any? ~ Ari English is like a pseudo-random number generator - there are a bajillion rules to it, but nobody cares.