On Tue, 11 Jan 2005, Larry Guest wrote:
Any thoughts?
You want to replicate the `tee` command. From its manpage:
NAME
tee - pipe fitting
SYNOPSIS
tee [-ai] [file ...]
DESCRIPTION
The tee utility copies standard input to standard output, making
a copy in zero or more files. The output is unbuffered.
The following options are available:
-a Append the output to the files rather than overwriting them.
-i Ignore the SIGINT signal.
The following operands are available:
file A pathname of an output file.
The _Perl Cookbook_ has recipies showing how to replicate this
behavior, e.g.:
open(MANY, "| tee file1 file2 file3 > /dev/null") or die $!;
print MANY "data\n" or die $!;
close(MANY) or die $!;
Or, to make the print statements simpler,
# make STDOUT go to three files, plus original STDOUT
open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
print "whatever\n" or die "Writing: $!\n";
close(STDOUT) or die "Closing: $!\n";
Or look on CPAN for modules like Tie::Tee and IO::Tee.
--
Chris Devers