You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Martin Haase-Thomas <mh...@meome-ag.de> on 2002/03/06 14:36:12 UTC
[OT] redirect STDOUT
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?
desperate
Martin
--
http://www.meome.de
-------------------------------------------------------
Martin Haase-Thomas | Tel.: 030 43730-558
meOme AG | Fax.: 030 43730-555
Software Development | mht@meome-ag.de
-------------------------------------------------------
Re: [OT] redirect STDOUT
Posted by Martin Haase-Thomas <mh...@meome-ag.de>.
Thanx a lot, you saved my life!
Geoffrey Young wrote:
>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 :)
>
--
http://www.meome.de
-------------------------------------------------------
Martin Haase-Thomas | Tel.: 030 43730-558
meOme AG | Fax.: 030 43730-555
Software Development | mht@meome-ag.de
-------------------------------------------------------
Re: [OT] redirect STDOUT
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
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 :)