| On 10 Dec 2002 12:09:13 -0800, geoflorida2000 / yahoo.com (George)
| >I want to write command line Ruby program whose arguments will be a
| > list of words to be found within all HTML documents of the current
| > directory. The output of the program will be a text file called
| > results.txt and will consist of a list of all HTML documents in which
| > one of the words appeared. Have the program create a subdirectory
| > called FINAL ,of the current directory and save results.txt there.
| > Finally, it will make duplicate copies of each of the files listed in
| > results.txt within the FINAL directory.
| > Any help would be greatly appreciated
| > George

George,

Here's my try at it; AKAIK it's platform independent.  Note I included regex 
support.

[Calling the script multiple times with different arguments will screw up the 
results-- FINAL should be deleted after every use-- this can be added to the 
script.]

---

#!/usr/bin/ruby -w

require 'ftools'

DIR          = 'FINAL'
RESULTS  = File::join DIR, 'results.txt'

class PageHarvest
  def initialize words
    @matches = []
    Dir['*.htm?'].each do |file|
      data = File::read file # for 1.6.7:  File::open(file){ |f| f.read }
      words.each do |word|
        if not @matches.include?(file) 
          # change below to: data.include?(word)
          # if you don't want regexes
          @matches << file if data =~ /#{word}/
        end
      end
    end
    finalize unless @matches.empty?
  end
  def finalize
    Dir::mkdir(DIR) unless File::directory?(DIR)
    File::open(RESULTS, 'w') do |results|
      @matches.each do |match| 
        results.puts match 
        File::copy match, File::join(DIR, match) 
      end
    end
  end
end

# runtime...
PageHarvest.new(ARGV) if __FILE__ == $0
---

(and yes, I'm aware it might be a bit much to write a Class for such a simple 
thing-- but how could I let a name like 'PageHarvest' go to waste? ;-)

Hope this helps,
-- Bruce

-- 
Bruce R. Williams :: [iusris/#ruby-lang] :: http://www.codedbliss.com

  'It does not require a majority to prevail, but rather an irate,
  tireless minority keen to set brush fires in people's minds.'
  -- Samuel Adams