From: "Paul D. Kraus" Date: 2006-05-16T22:22:34+09:00 Subject: GetoptLong Accessing the values with out looping ------=_Part_42376_5789675.1147785750587 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Simple question but for the life of me I can't figure it out. I am converting some of my basic perl scripts that I use daily as an excersice in learning ruby. I need to grab a date from the command line that will eventually be converted into a filename. no I want to call my script like such ... ./myscript.rb -d 2006-08-06 I then want to validate what is being set in -d. Here is the code I have that works but it just seems excessive to have to loop through the options... def getopts opts =3D GetoptLong.new([ '-d', '--date', GetoptLong::REQUIRED_ARGUMENT]) opts.each do |opt,arg| if opt =3D~ /-d|--date/ && arg =3D~ /(\d{4})-(\d{2})-(\d{2})/ date =3D arg.gsub('-','') return date else puts "Date needs to be set to YYYY-MM-DD using -d or --date" exit end end end I thought I would just be able to do... if opt['-d'] =3D~ || opt['--date'] =3D~ end Thanks. Paul Kraus ------=_Part_42376_5789675.1147785750587--