You can use tee.  (man tee, the really strong tee)

open (STDOUT, "| tee file1 file2 file3");
print "whatever\n";
close(STDOUT);

I'm not sure how that would work with your other pipes, or if you can
open a file handle and 'tee' to another file handle?

There's probably a perl module that does it too, probably with a lot
more functionality.

-Rob

> On 20020307.1508, Cory Petkovsek said ...
>
> How can I simultaneously print to two streams in perl?
> 
> open(LOG, "|perl -pe 's/\r//g'| ntlogformat 9 $delim \"\t\" ".
>     ">>$tmp_logfile") or die "Can't >> $tmp_logfile $!";
> 
> open(ARCH, "|ssh svc_ntlogs\@$arch_host \"cd $arch_dir; cat >$logfile\"");
> 
> print LOG &ssh($log_ssh, "el/eldump -l application -l system ".
>     "-l security -K -Q -c $delim -x //$log_host");
> print ARCH &ssh($log_ssh, "el/eldump -l application -l system ".
>     "-l security -K -Q -c $delim -x //$log_host");
> 
> 
> ARCH is a pipe opened via an ssh connection to a remote server to a
> remote file.  
> LOG is a pipe to a local file (after some formatting).
> 
> I know I can merge two streams:
> open(STDOUT, ">file");
> open(STDERR, ">&STDOUT");
> 
> Maybe I can fork a stream?
> 
> Thanks,
> Cory
> 
> 

--
Rob <rob_at_euglug_dot_net>
my @euglugCode = qw(v+++ e--- eug+ bsd+++ gnu+ S+++);

Reply via email to