title: How to determine if shell command didn't run or produced no output
body: <p>I am executing some shell commands via a perl script and capturing output, like this,</p>
  
  <pre><code>$commandOutput = `cat /path/to/file | grep "some text"`;
  </code></pre>
  
  <p>I also check if the command ran successfully or not like this,</p>
  
  <pre><code>if(!$commandOutput)
  {
      # command not run!
  }
  else
  {
      # further processing
  }
  </code></pre>
  
  <p>This usually works and I get the output correctly. The problem is, in some cases, the command itself does not produce any output. For instance, sometimes the text I am trying to <code>grep</code> will not be present in the target file, so no output will be provided as a result. In this case, my script detects this as "command not run", while its not true.</p>
  
  <p>What is the correct way to differentiate between these 2 cases in perl?</p>