Rajini Naidu wrote:
 Hi,

Hello,

I have the below commands in the script.

`$swlist -l bundle -a revision -a architecture -s $t | $grep $n >>
$log_our_depot`;

`$swlist -l bundle -a revision -a architecture -s $t | $grep $n >>
$log_ourdepot_comp`;

Here I am outputting the same command line output to different logfile.
Is there a way in perl where I can output in one pass by storing it in a
variable.

open my $LOG1, '>>', $log_our_depot or die "Cannot open '$log_our_depot' $!"; open my $LOG2, '>>', $log_ourdepot_comp or die "Cannot open '$log_ourdepot_comp' $!";

open my $PIPE, '-|', $swlist, '-l', 'bundle', '-a', 'revision', '-a', 'architecture', '-s', $t
    or die "Cannot open pipe from '$swlist' $!";

while ( <$PIPE> ) {
    next unless /$n/;
    print $LOG1 $_;
    print $LOG2 $_;
    }

close $PIPE or warn $! ? "Error closing '$swlist' pipe: $!"
                       : "Exit status $? from '$swlist'";




John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to