home *** CD-ROM | disk | FTP | other *** search
- package IO::Tee;
-
- =head1 NAME
-
- IO::Handle - supply object methods for I/O handles
-
- =head1 SYNOPSIS
-
- use IO::Tee;
-
- open(LOG, ">Logit");
-
- tie *EARL_GREY, q(IO::Tee), *STDOUT, *LOG;
-
- select(EARL_GREY);
-
- printf "%s\n", "Hello, World";
-
- =head1 DESCRIPTION
-
- C<IO::Tee> emulates a bit of the functionality of the UN*X F<tee> program.
- Everything printed to an C<IO::Tee> file handle will be printed to all
- file handles given as arguments to the tie. That's all, folks.
-
- =head1 SEE ALSO
-
- L<perltie>
-
- =head1 AUTHOR
-
- Matthias Neeracher E<lt>F<neeri@iis.ee.ethz.ch>E<gt>
-
- =cut
-
- BEGIN {
- use strict;
-
- use Carp;
- use Symbol;
- }
-
- sub TIEHANDLE {
- my @proxies = @_;
- shift @proxies;
-
- bless \@proxies;
- }
-
- sub PRINT
- {
- croak 'Usage: print [FILEHANDLE|$filehandle] @items;'
- if (@_ < 1);
-
- my($proxies) = shift;
-
- for my $handle (@$proxies) {
- print $handle @_;
- }
- }
-
- sub PRINTF
- {
- croak 'Usage: print [FILEHANDLE|$filehandle] $format, @items;'
- if (@_ < 2);
-
- my($proxies) = shift;
- my($format) = shift;
- $format = sprintf($format, @_);
-
- for my $handle (@$proxies) {
- print $handle $format;
- }
- }
-
- 1;
-
-