[Israel.pm] print to 2 places at the same time
srikanth.madani at vodafone.com
Wed Jun 2 01:07:02 PDT 2004
Offer Kaye wrote:
> This happens even of I do "$|=1;" at the beginning of the script.
BTW, from what I understand, the $| variable does not guarantee that the OS
will actually perform an instantaenous write.
Can someone comment on this?
>I would suggest to use a Perl module named IO:Tee from CPAN. Never tried
>it, but how bad can it bee? ("bee" as in "tee").
Yes, IO:Tee is an alternative; here's sample code that uses it.
#Multiplex output to multiple output handles
my $tee = IO::Tee->new ( ">$first_file", ">$second_file");
#Bind $tee to $first_file and $second_file
#Notice that file handles are not used.
$| = 1;
print $tee "\nMail comments about $0 to
#Flush the output buffer
Murphy's Law is recursive. Washing your car to make it rain doesn't work.
More information about the Perl