pm5 has asked for the wisdom of the Perl Monks concerning the following question:
I thought this should work:use IO::Handle; use IO::File; my $out = IO::File->new('output.txt', 'w') or die $!; STDOUT->fdopen($out, 'w') or die $!; print "hello, world!";
Alas it does not. I'm trying to save the printed output of 3rd party code in a string for further use. How do I do this?use IO::Handle; use IO::Scalar; my $data = ''; my $out = IO::Scalar->new(\$data) or die $!; STDOUT->fdopen($out, 'w') or die $!; print "hello, world!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I redirect STDOUT to a string?
by jZed (Prior) on Jun 23, 2004 at 05:02 UTC | |
|
Re: How do I redirect STDOUT to a string?
by BrowserUk (Patriarch) on Jun 23, 2004 at 06:35 UTC | |
|
Re: How do I redirect STDOUT to a string?
by leriksen (Curate) on Jun 23, 2004 at 05:00 UTC | |
|
Re: How do I redirect STDOUT to a string?
by slife (Scribe) on Jun 23, 2004 at 07:45 UTC | |
|
Re: How do I redirect STDOUT to a string?
by DrHyde (Prior) on Jun 23, 2004 at 08:47 UTC | |
|
Re: How do I redirect STDOUT to a string?
by Anonymous Monk on Jun 23, 2004 at 22:42 UTC |