#!/usr/bin/perl

#hash trick to make an array with unique values from an array with repeated values

@a=(42, 3847, 38, 42, 998, 20, 3, 38, 1123, 20);

%tmp;
foreach $num (@a){
  $tmp{$num}++;  
  print "How many times has $num accured?\t$tmp{$num}\n";
}
@b = keys( %tmp );
print "@b\n";


