If you don't want to change the code in the subroutine to accumulate and return a string, instead of printing, you can try the following. Similar but prettier techniques use non-standard modules.
# 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>";
Btw - this question is a (currently unapproved)
Categorized Question:
How can I write a function's output to a scalar?.
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.