Mod_ruby -- Problem with Changing from $defout > $stdout

Hi,

I'm working on upgrading some Ruby 1.6.x to prepare for a web-server wide upgrade to 1.8.2 (We're still running under 1.6.x). $defout is obsolete in Ruby 1.8.2. In irb, $defout==$stdout, so I would think that I should be able to replace any usage of $defout in a script with $stdout. But it doesn't work!

Take the code below. I would expect to be able use either "$defout = out" and "$defout = starting_stdout" OR "$stdout = out" and "$stdout = starting_stdout". However, only the $defout lines work

Interestingly, while $stdout==$defout is true in irb, it is false in mod_ruby as puts puts ($stdout==$defout)==false true.

What am I doing wrong? Why does $stdout==$defout in irb but not in mod_ruby?

Ben

class ...
def get_output
        starting_stdout = $stdout
        begin
            out = Object.new
            class << out
                attr_reader :output
                def write(value)
                    @output ||= ''
                    @output << value.to_s
                end
                alias << write
                def flush(*args) end
            end
            ## Either of these lines should result in the same effect, correct?
            $defout = out
            #$stdout = out
            yield
        ensure
            ## Again, these two lines are identical in function, right?
            $defout = starting_stdout
            #$stdout = starting_stdout
        end
        puts ($stdout==$defout)==false
        return out.output
    end
end

I moved this message over to the mod_ruby list. -bdg