First, we set up a bunch of access points:
my $hub = IO::TieCombine->new;
my $str_ref = $hub->scalar_ref(x);
my $fh = $hub->fh(x);
my $callback = $hub->callback(x);
tie my $scalar, $hub, x;
tie local *STDOUT, $hub, x;
tie local *STDERR, $hub, err;
Then we write to things:
$$str_ref .= And ;
print $fh "now ";
$scalar .= something ;
print "completely ";
$hub->combined_contents; # And now for something completely different.
$hub->slot_contents(x); # And now for something completely
$hub->slot_contents(err); # different.
<B>ACHTUNG!!B> Because of a serious problem with Perl 5.10.0, output sent to a
tied filehandle using say <B>will not have the expected newlineB>. 5.10.1 or
later is needed. Since 5.10.0 is broken in so many other ways, you should
really upgrade anyway.
<B>ACHTUNG!!B> Because of a different problem with Perls 5.10.1 - 5.16.3, if you
send output to a tied filehandle using say, and $\ is undefined (which is
the default), <B>B>$\<B> will not be restored to B>undef<B> after the B>say<B>B>!
This means that once youve used say to print to any tied filehandle, you
have corrupted the global state of your program. Either start your program by
setting $\ to an empty string, which should be safe, or upgrade to 5.18.0.