From: Robert Gleeson 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 Command line options are stored in the ARGV array. ./assignment2.rb --verbose ARGV[0] # => "--verbose" If no command line options are supplied, ARGV will be empty. Also look at `optparse` in the standard library for handling more complex command line options. Rob -- Posted via http://www.ruby-forum.com/.