Hi,
   
     I've an array storing some numbers , out of which few are duplicate.
  I'd like to skip those which are duplicate and save them in a new array and 
same time I wish to count the number of skipped/duplicate elements.
   
  Eg:- 
   
  Given Array "fields" {12,12,12,12,17,20,25,100,100,100}
   
  Expected Output :- Array "unique_elements"  {12,17,20,25,100}
   
  Count Information based upon "Array "fields" & Array "unique_elements" :- 
   
     12 appeared 4 times
     17 appeared once
     20 appeared once
     25 appeared once
     100  appeared 4 times
   
  -----------------
  my @fields =();
  my @unique_elements=();
  my %seen   = ();
   
   
      foreach my $elem (@fields) {
      next if $seen{ $elem }++;
      push (@unique_elements, $elem);
    }
-----------------
   
  What needs to be done to compute the count of skipped/duplicate elements ?
   
  Thanks,
   
  Rinku

 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

Reply via email to