in reply to Re: Re: How to collect the stdout of a subroutine call?
in thread How to collect the stdout of a subroutine call?
Btw - this question is a (currently unapproved) Categorized Question: How can I write a function's output to a scalar?.# somewhere near the top of your code, put this: { package AccumHandle; sub TIEHANDLE { my( $pkg, $s ) = shift; bless \$s, $pkg } sub PRINT { my $self = shift; $$self .= join($,,@_).$\; } } # now do this where you call the subroutine: local ACC; tie *ACC, 'AccumHandle'; select ACC; &log(); select STDOUT; my $xx = ${tied(*ACC)}; print "<b>$xx</x>";
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|