[EMAIL PROTECTED] writes:
> Scott Dial <[EMAIL PROTECTED]> writes:
>
>> Try:
>> http://search.cpan.org/~kenshan/IO-Tee-0.64/Tee.pm
>
>>> ===
>>> Something I've wanted a few times was a way to write to two places at
>>> once or really I mean with one print call.
>>>
>>> Something like:
>>> print FILE1 FILE2 "something\n";
>>> or
>>> print FILE TTY "something\n";
>>>
>>> Is there some nifty way to do that?
>
> That looks promising... thanks.
Well I thought so until I discovered I couldn't make heads or tails of
the example given.
use IO::Tee;
$tee = IO::Tee->new($handle1, $handle2);
print $tee "foo", "bar";
my $input = <$tee>;
Trying to see something of how it works:
#!/usr/local/bin/perl -w
use IO::Tee;
my ($handle1, $handle2);
$handle1 = "./one"
$handle2 = "./two"
$tee = IO::Tee->new($handle1, $handle2);
print $tee "foo", "bar";
my $input = <$tee>;
print $input;
$ ./io.pl
Use of uninitialized value in open at \
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/IO/File.pm line 176.
Can't use an undefined value as a symbol reference at ./io.pl line 7.
Adding opens for the filehands doesn't help; it still won't run:
#!/usr/local/bin/perl -w
use IO::Tee;
# use diagnostics;
my ($handle1, $handle2);
$handle1 = "./one";
$handle2 = "./two";
open(FILE,"+>$handle1");
open(FILE2,"+>$handle2");
$tee = IO::Tee->new($handle1, $handle2);
print $tee "foo", "bar";
my $input = <$tee>;
#print $input;
Error output:
Scalar found where operator expected at ./io.pl line 5, near "$handle2"
(Missing semicolon on previous line?)
syntax error at ./io.pl line 5, near "$handle2 "
Execution of ./io.pl aborted due to compilation errors.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>