title: How to get the value from the list that appears only once?
body: <p>I saw this question in the internet. Get the only number that is present only once in the list while other numbers are present twice in the list. The data is large and contains about a million numbers unsorted and may contain negative numbers too of random order out of which all numbers appear twice except one number that appears only once. </p>
  
  <pre><code>my @array = (1,1,2,3,3,4,4)
  </code></pre>
  
  <p>output :</p>
  
  <pre><code>2
  </code></pre>
  
  <p>Only two is not repeated in the list. I tried my solutions.</p>
  
  <pre><code>my $unique;
  $unique ^= $_ for(@array);
  say $unique;
  </code></pre>
  
  <p>It doesn't work on negative numbers but fast.</p>
  
  <p>I tried a hash where key is the number and value is the number of times its present in the list. Reverse the hash and then print the value with 1 as key as all other numbers have 2 as key as they appear twice. The hash solution is slow with a large input of one million numbers but works for negative numbers.</p>
  
  <p>I tried a regex way of combining the entire list with tab and then used </p>
  
  <pre><code>my $combined = join " ", @array;
  $combined !~ (\d+).*$1;
  say $1;
  </code></pre>
  
  <p>but I get only the last number of the list</p>
  
  <p>Is there a fast way to do it? Any idea of using a regex? </p>
  
  <p>Edit : Repharsed the title for better answers</p>