Loading ...
Sorry, an error occurred while loading the content.

27413Remove duplicate keys from a hash

Expand Messages
  • Md. Musfique Anwar
    Nov 28, 2012
      Hi,

      I want to know is there any way to detect duplicate keys in hash.

      I have a CDB database and from that I create hash and the hash contains
      duplicate keys. I want to remove duplicate keys from hash. Below I gave my
      sample perl code:

      --------------------------------------------

      my @arr = (1,2,1,4);

      my $db = new CDB_File ("test_cdb.cdb", "test_cdb.$$") or die "$!";

      for(my $i=0; $i < 4; $i++){

      # print "$arr[$i]\n";
      $db->insert($arr[$i], $arr[$i] . "=" . 10);
      }

      $db->finish;

      tie %data, 'CDB_File', "test_cdb.cdb" or die;

      while(my ($k, $v) = each %data){
      print "$k -> $v\n";
      }

      --------------------------------------------

      regards-

      Musfique


      [Non-text portions of this message have been removed]
    • Show all 2 messages in this topic