On May  2, Andrew Walrond wrote:
> I'm new to ruby, so forgive any obvious stupididity, but can anyone 
> enlighten me as to why this...
> 
> #!/usr/bin/ruby -w
> 
> File.open("output","w") { |f|
>   puts("To the screen")
>   sso = $stdout
>   $stdout=f
>   puts("To the file")
>   $stdout = sso
>   puts("To the screen again")
> }
> 
> does this...
> 
> root@bob rubyx # ./test
> To the screen
> root@bob rubyx # cat output
> To the file
> To the screen again

I don't see the same behavior:

vor-lord:/tmp> ruby -e 'File.open("output","w") { |f|
  puts("To the screen")
  sso = $stdout
  $stdout=f
  puts("To the file")
  $stdout = sso
  puts("To the screen again")
}
'
To the screen
To the screen again
vor-lord:/tmp> cat output
To the file
vor-lord:/tmp> ruby -v
ruby 1.7.2 (2002-02-21) [i386-linux]


This appears to be version specific:

vor-lord:/tmp> /usr/bin/ruby -e 'File.open("output","w") { |f|
  puts("To the screen")
  sso = $stdout
  $stdout=f
  puts("To the file")
  $stdout = sso
  puts("To the screen again")
}
'
To the screen
vor-lord:/tmp> cat output
To the file
To the screen again
vor-lord:/tmp> /usr/bin/ruby -v
ruby 1.6.7 (2002-03-19) [i386-linux]