Rob Dixon <[email protected]> writes:
> On 27/08/2013 23:06, John W. Krahn wrote:
>> Harry Putnam wrote:
[...]
>>> (Simplified for discussion, from a longer script)
>>>
>>> my $rsync = 'rsync';
>>> my $tmplog = 'one.log';
>>> my $tmplog2 = 'two.log';
>>> open(LOG,">>$tmplog")or die "Can't open $tmplog : $!";
>>> open(LOG2,">>$tmplog2")or die "Can't open $tmplog2: $!";
>>> print LOG "kdkdkdkd Output from:\n$rsync cmdflgs";
>>> print LOG2 "kdkdkdkd Output from:\n$rsync cmdflgs"
>>> close(LOG);
>>> close(LOG2);
>>>
>>> Is there some smooth way to write to more than one log?
>> my %logs = (
>> 'one.log' => undef,
>> 'two.log' => undef,
>> );
>>
>> for my $name ( keys %logs ) {
>> open my $FH, '>>', $name or die "Cannot open '$name' because: $!";
>> $logs{ $name } = $FH;
>> }
>>
>> for my $log_FH ( values %logs ) {
>> print $log_FH "kdkdkdkd Output from:\n$rsync cmdflgs";
>> }
>
> Nice John
Yes very nice... thank you John
> It compacts neatly to
[...] snipped neatly compacted code
Nicely compacted... thank you Rob.
Thanks to all other posters.. lots of good input.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/