title: Making a perl array unique
body: <p>I am currently having a very simple problem with capturing the output from a backticked shell command. I apologize that the problem is rather simple. </p>
  
  <p>I have some sorted array (@valid_runs) which I <strong>know</strong> contains consecutive, duplicate elements. I want to use backticks to echo this array to uniq. I want to capture the STDOUT in an array. I attempt to do so like this.</p>
  
  <pre><code>@unique_valids = `echo '@valid_runs' | uniq`;
  print @unique_valids;
  </code></pre>
  
  <p>This print statement yields nothing. For that matter neither does this.</p>
  
  <pre><code>@unique_valids = `echo '@valid_runs'`;
  print @unique_valids;
  </code></pre>
  
  <p>I know how to use uniq and echo. This seems rather odd to me. I would think this has more to do with perl arrays than proper use of those commands. I have searched around a bit elsewhere, so please don't pelt me with downvotes just because the solution might seem trivial. Thanks again for your time.</p>
  
  <p>NOTE on solutions:
  TLP's solution is the most straightforward as far handling the uniq problem. I am being rather flexible, since all responses suggested not making a system call for this problem. If Perl's uniq function the same as Unix's uniq then the array ought to remain sorted.</p>
  
  <p>John Corbett's solution works well if you don't care about a sorted result.</p>