Perl Monk, Perl Meditation | |
PerlMonks |
Challenge: Capturing stdout from a function call.by BUU (Prior) |
on Oct 21, 2004 at 09:05 UTC ( [id://401093]=perlquestion: print w/replies, xml ) | Need Help?? |
BUU has asked for the wisdom of the Perl Monks concerning the following question:
Heres the basic situation. I have a function call. When I run it, it prints stuff to stdout. I wish to have this in a variable instead. Here is the code that prints to stdout:
In case you are unfamiliar with the module in question, it is Perl.pm in the bundle named "PerlInterp-0.03" on cpan. Yes, in case you are curious, I have tried reopening stdout to a scalar reference, using io::capture::stdout, tying stdout, etc. No luck so far. Update: In case anyone cares, none of the solutions presented actually work. (Except for possibly the first one that Anonymous Monk suggested, as I can't get open FOO,"-|"; to do anything useful on win32) Update2: The reason none of these solutions work, is Perl.pm gets it's own filedescriptors from the kernel (or something like that), so all the perl magic you want to do doesn't affect the file descriptors Perl.pm eventually gets.
Back to
Seekers of Perl Wisdom
|
|