in reply to Printing to multiple file handles with one request

You should create a sub-routine that handles these for you. For example:
sub mprint { my @fh; push(@fh, shift) while (ref($_[0]) eq 'GLOB'); print $_ @_ foreach (@fh); } open($so, ">&STDOUT"); open($se, ">&STDERR"); mprint $se, $so, "This tests\n";
It's not quite as clean as the builtin, but it's pretty close. You could even group your filehandles together into array packages, so that it's tidier:
my @default = ($so); my @log_and_print = ($log, $so); mprint @default, "Standard message\n"; mprint @log_and_print, "This goes to log and screen\n";
Update:
IO::Tee looks like a great way to do this as well, provided you can install your own modules.

Replies are listed 'Best First'.
Re: Re: Printing to multiple file handles with one request
by gnu@perl (Pilgrim) on Nov 19, 2002 at 15:42 UTC
    Yeah, this is pretty much what I had done, I was hoping there was a way 'built in' to standard perl. Installing modules is a little difficult due to the position of management.

    Sometimes I don't state what I have already done because it seems to taint the responses from time to time. I like to see fresh ideas and very often some really cool stuff come up.

    Thanks for your help!