in reply to Challenge: Capturing stdout from a function call.

I asked a similar quetion sometime back: How to capture STDOUT/STDERR of a function. One solution from there was:
use strict; my $out; { open local(*STDOUT), '>', \$out; foo(); } print "Std: $out\n"; sub foo{ print "from foo"; }

Replies are listed 'Best First'.
Re^2: Challenge: Capturing stdout from a function call.
by melora (Scribe) on Oct 21, 2004 at 23:33 UTC
    That looks like a really elegant solution. When I tried it on my system, I ended up with a file named SCALAR(0x17651f0) containing "from foo". What am I missing?
      perl5.8 probably.