The results of my little script here confuse me. I looking for an odd 
number of pages in postscript files. When it's an odd number, I add a 
blank, to make an even page count. In my test here, I've got 2 test 
postscript files. One has 11 pages; the other has 42 pages. As can be 
seen by my results below this script, it's seeing both as odd numbered, 
and, it's adding a blank to each. Is my formula for MOD not correct? 
I've tried it with "not equal to zero," like here, and, I've tried it 
with "equal to one," with the same results.

Dir.chdir('c:/scripts/ruby/temp')
psfiles = Dir.glob('*.ps')
psfiles.each do |psfile|
  File.open(psfile, "a") do |writepage|
  	File.read(psfile).scan(/\%\%Pages: (\d{1,5})\n/) do
  	  numberofpages = $1
    	#Diagnostic to see the page counts of each file.
    	puts numberofpages
    	#If the page count is odd, then,
          #add a blank to make it an even page count.
    	if (numberofpages % 2) !=0 then
      	#Diagnostic--what is it seeing?
      	puts "odd number of pages"
      	writepage << "showpage\n"
    	end
  	end
  end
end


C:\scripts\RUBY\temp>c:\scripts\ruby\images\test4.rb
42
odd number of pages
11
odd number of pages

Thank you, anyone, who can help me with this. . . .

-- 
Posted via http://www.ruby-forum.com/.