title: Get return code and output from command in Perl
body: <p>I'm trying to write a utility that will go through a file that would look like this: </p>
  
  <pre><code># Directory | file name | action | # of days without modification to the file for the command to take action
  /work/test/|a*|delete|1
  /work/test/|b*|compress|0
  /work/test/|c*|compress|1
  </code></pre>
  
  <p>My script will go through the file deciding if, for example, there are files under /work/test/ that start with 'a' that haven't been modified in the last 1 days, and if so, it would delete them. </p>
  
  <p>For this, I use the find command. Example: </p>
  
  <pre><code>my $command = "find " . $values[0] . $values[1] . " -mtime +" . $values[3] . " -delete ;\n";
  system ($command);
  </code></pre>
  
  <p>But, I've been asked to retrieve the return code for each step to verify that the every step worked fine. </p>
  
  <p>Now, I know that system() returns the return code, and the backticks return the output. But, how can I get both? </p>