title: Get unique elements from HoA values and print
body: <p>I have a HoA with certain values in it.</p>
  <p>I need to have only unique elements from the HoA.</p>
  <p><strong>Expected Result:</strong></p>
  <pre><code>Key:1
  Element:ABC#DEF
  Key:2
  Element:XYZ#RST
  Key:3
  Element:LMN
  </code></pre>
  <p>Below is my script:</p>
  <pre><code>#!/usr/bin/perl
  
  use strict; use warnings;
  use Data::Dumper;
  
  my %Hash = (
              '1' =&gt; ['ABC', 'DEF', 'ABC'],
              '2' =&gt; ['XYZ', 'RST', 'RST'],
              '3' =&gt; ['LMN']
  );
  
  print Dumper(\%Hash);
  
  foreach my $key (sort keys %Hash){
      print &quot;Key:$key\n&quot;;
      print &quot;Element:&quot;, join('#', uniq(@{$Hash{$key}})), &quot;\n&quot;;
  }
  
  sub uniq { keys { map { $_ =&gt; 1 } @_ } };
  </code></pre>
  <p>The script throws me following error:</p>
  <pre><code>Experimental keys on scalar is now forbidden at test.pl line 19.
  Type of arg 1 to keys must be hash or array (not anonymous hash ({})) at test.pl line 19, near &quot;} }&quot;
  Execution of test.pl aborted due to compilation errors.
  </code></pre>
  <p>If I use <code>List::Util</code>'s <code>uniq</code> function to get the unique elements with following statement, I am able to get the desired result.</p>
  <pre><code>use List::Util qw /uniq/;
  ...
  ...
  print &quot;-Element_$i=&quot;, join('#', uniq @{$Hash{$key}}), &quot;\n&quot;;
  ...
  </code></pre>
  <p>Since I have <code>List::Util</code>'s <code>1.21</code> Version installed in my environment, which doesn't support <code>uniq</code> functionality as per the <a href="https://metacpan.org/pod/List::Util#uniq" rel="nofollow noreferrer">List::Util documentation</a>.</p>
  <p>How can I get desired result without using <code>List::Util</code> module.</p>
  <p><strong>Update/Edit:</strong></p>
  <p>I found a solution by adding this line in print statement:</p>
  <pre><code>...
  print &quot;Element:&quot;, join('#', grep { ! $seen{$_} ++ } @{$Hash{$key}}), &quot;\n&quot;;
  ...
  </code></pre>
  <p>Any suggestion would be highly apricated.</p>