in reply to Printing to multiple file handles with one request
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: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";
Update: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";
|
|---|
| 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 |