From: Chad Fowler Date: 2003-11-29T11:11:32+09:00 Subject: Re: How to p to a string On Sat, 29 Nov 2003, Carl Youngblood wrote: # Is there a way that I can cause p to store the output that it would have # sent to STDOUT into a string instead? # You could do something ugly like: my_stringio = StringIO.new $stdout = my_stringio p "blah" $stdout = STDOUT puts my_stringio.string The "p" method as defined sends output to $stdout (or, more accurately, "rb_stdout" in C). So you have to redefine $stdout to redirect its output. Alternatively, you could redefine "p". Chad