in reply to Appending print to a variable
If your using 5.8, you could also use an "in memory file". See perlfunc:open pod from 5.8 for details, but basically this involves closing STDOUT and then re-opening it to a scalar ref.
close STDOUT; open STDOUT, '>', \my $buffer or die $!; print ....; # This will append the output to $buffer
Alternatively, you could open another filehandle to a scalar and then select that filehandle as the default output stream prior to your print statements and select back when your ready to print output to STDOUT.
|
|---|