From: Gavin Sinclair Date: 2002-12-01T23:14:00+09:00 Subject: Re: getoptlong From: > Hi, > > I'm completely new to ruby, used perl until now. > In perl I can say: > > 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? > > Can I find some examples of ruby somewhere to learn things like this? Not as far as I know, since global variables are considered bad style, in general, in Ruby programming. The deprecated "getopts" library set global variables - chance or coincidence? A Ruby reference - try online PickAxe - will detail what you can and can't do. As for me, I just set default values before I parse the options (like this, since you're a Perler): opts.each do |option, arg| case option when '-o' then output_target = arg when '-O' then optimization = arg when '-g' then debug = true end end Gavin