From: "Marvin Gülker" Date: 2009-11-04T03:18:21+09:00 Subject: Re: ruby script with flag Jillian Kozyra wrote: > Hi, > > I am trying to write a ruby script which accepts a flag. That is, I > would like to execute the script by doing: > ./assignment2.rb --verbose OR > ./assignment2.rb > > How would I got about making the script accept a flag? > > Thanks, > Jillian Every command-line argument that you pass into a Ruby script is available via the ARGV aray. Therefore, if you call a script with ./assignment2.rb --verbose then ARGV[0] is "--verbose". Because command-line-option-handling (what a word!) can be a bit cumbersome, you could use a library like OptionParser (in the stdlib as "optparse"). Marvin -- Posted via http://www.ruby-forum.com/.