From: nobu.nokada@... Date: 2002-12-01T23:14:36+09:00 Subject: Re: getoptlong Hi, At Sun, 1 Dec 2002 21:27:47 +0900, wybo@servalys.nl wrote: > GetOptions('--option',\$option); > warn "--option was set\n" if $option; > > In ruby, the first line would become: > > opts=GetoptLong.new( > [ "--option", "-o", GetoptLong::NO_ARGUMENT ] > ) > > But I see no simple way to straightforwardly test whether --option was > set. Is there a way? opts.each do |opt, arg| case opt when "--option" $option = true end end If you want to use optparse.rb (distributed with 1.7): ARGV.options do |opt| opt.def_option("--option", "-o") {$option = true} opt.parse! end -- Nobu Nakada