title: How can I run an external command and capture its output in Perl?
body: <p>I'm new to Perl and want to know of a way to run an external command (call it <code>prg</code>) in the following scenarios:</p>
  
  <ol>
  <li>Run <code>prg</code>, get its <code>stdout</code> only.</li>
  <li>Run <code>prg</code>, get its <code>stderr</code> only.</li>
  <li>Run <code>prg</code>, get its <code>stdout</code> and <code>stderr</code>, separately.</li>
  </ol>