Martin Haase-Thomas wrote:
> 
> Hi all,
> 
> instead of committing suicide after having tried and searched for all of
> the day now i'd rather ask you:
> does anyone know how to redirect STDOUT into a scalar variable,
> so that a 'print "anything"' will not appear on STDOUT, but only in
> my buffer?

try taking a look at Recipe 6.10 in the Cookbook (http://www.modperlcookbook.org/)...

basically...

tie *STDERR 'SomeClassThatImplementsTIEHANDLE'

# do something that writes to STDERR

untie *STDERR

the TIEHANDLE implementation can be anything you want: Apache (to send to your 
browser), IO::String
or IO::Scalar (to send to a variable), or whatnot...

there's also an example in the Guide
http://perl.apache.org/guide/porting.html#Redirecting_STDOUT_into_a_Scalar

HTH

--Geoff
# who is now contemplating a .sig for the first time :)

Reply via email to