From: RichardOnRails Date: 2007-12-04T14:05:02+09:00 Subject: Rubyisms wanted to shorten code in search program Hi, Search on WindowsXP/SP2 didn't seem to locate a file is looking for. As someone relatively new to Ruby, I wonder whether there are any Rubyisms I could have used to cut down the the 80+ lines I took to accomplish this task, given the USAGE requirement I posed in the code. Thanks in Advance, Richard # Search.rb # K:/_Projects/Ruby/_Ruby_Tests/TestSearchDir/SearchWithArgs # USAGE: Search.rb -d DirPath [-f regexpFileNameSought] [-t regexpTextSought] require 'find' def Match(path, reTxt) open(path) { |f| f.each_line { |line| if (line =~ reTxt) puts "MATCH found in following line" puts line return true end } } return false end def ShowQuit(msg, arg = '') puts "ERROR " + "="*10, msg + ": " + arg, "="*16 exit end argPrefix = '-' argFlags = %{d f t} # reDirectory, reFilename, reText argVals=Hash.new #args = "-d K:/_Projects/Ruby/_Ruby_Tests -f search.*[.]rb$ -t curArg".split(' ') args = "-d K:/_Projects/Ruby/_Ruby_Tests -t curArg".split(' ') puts args.join(' ') ix = 0 while( ix