Peter Bailey schrieb:
> I'm going nuts with this tiny script.
> (...)

Peter, the problem with your script seems to be here:

> 9     totalpages = contents.scan(/^%%Page:.*[0-9]{1,5}$/) do
> 10    end

If you use String#scan with a block, the method returns the original 
string ("contents" in this case). See

   http://www.ruby-doc.org/core/classes/String.html#M001884

Try to remove the "do end" part.

Regards,
Pit