How can I print to a variable instead of a file, in Perl?
问题 How can I print to a variable with Perl? I've been working on a program for a while which logs its iterative progress in a highly verbose fashion... print $loghandle $some_message; However, I'd like to also selectively print some of the messages to a different file. Naturally, I could sprinkle the code with... print $loghandle $some_message print $otherloghandle $some_message Or rewrite the whole business into a function. Blah. What I want to do is do some magic when I open the $loghandle so