From: 7stud -- Date: 2008-02-20T16:51:34+09:00 Subject: Re: Need Help With OptionParser Try this one: require 'optparse' p ARGV puts non_wrapper_options = [] opts = OptionParser.new do |opts| #wrapper option where value is required: opts.on("-t=RANDOM_CHARS") do |val| puts "-t option entered with value=#{val}" end #wrapper option where value is optional: opts.on("-y [=RANDOM_CHARS]") do |val| puts "-y option entered with value=#{val}" end #non-wrapper option where value is optional: opts.on("-a[=RANDOM_CHARS]") do |val| puts "-a option entered with value=#{val}" non_wrapper_options << '-a' if val non_wrapper_options << val end end end opts.parse(ARGV) ARGV.replace(non_wrapper_options) puts p ARGV --output:-- $ ruby optparseEx2.rb -y -thello -a goodbye ["-y", "-thello", "-a", "goodbye"] -y option entered with value= -t option entered with value=hello -a option entered with value= ["-a"] -- Posted via http://www.ruby-forum.com/.