open my $PIPE, '-|', "/usr/openv/netbackup/bin/admincmd/bpcatlist -client $client 2>&1" or die "Cannot open pipe from 'bpcatlist' $!"; while ( <$PIPE> ) { next unless /$client/; $lastValidBackupTime = ( split )[ 1 ]; last; } close $PIPE or warn $! ? "Error closing 'bpcatlist' pipe: $!" : "Exit status $? from 'bpcatlist'";