my @command = ( $swlist, '-l', 'depot', '@', $depot_locn ); my $child_pid = open( my $shell, '-|', @command ) or die "shell command failed: $!\n"; open( my $out1, ">>", $log_std_depot ) or die "$log_std_depot: $!\n"; open( my $out2, ">>", $temp_log ) or die "$temp_log: $!\n"; print $out1 "COMMAND: @command ## FILTERS: $rel_string / $i / AR\n"; while (<$shell>) { next unless ( /$rel_string/ and /$i/ and /AR/ ); print $out1 $_; print $out2 $_; } close $out1; close $out2; close $shell;