trying to implement hash table. and getting lots of difficulties. plz help me out..........by Priti24 (Novice)
|on Oct 10, 2012 at 05:38 UTC||Need Help??|
Priti24 has asked for the
wisdom of the Perl Monks concerning the following question:
i m new to perl. and i am trying to implement hash table . firstly i took a hash like
i also took an array with 10 ten empty buckets like@buckets = ( ,,,,,,,,, );
after that i used a while loop and got key from there and after that i called a function perlhash to calculate the index of that key. after getting index of every particular key in hash , i pushed every key , value pair at index which i got from from perlhash function. if two keys having same index then it will store two keys at same index
now i want to search for a particular key existence and i want to get value for that key. how should i do that with my code.
suppose i want to search 37. then this $h giving me index of 37. and through $buckets[$h] i can get value like.
how could i get 37 from this code. also if i search for 47 then this will also gave me same index then i have to apply a comparison that at this index 47 does not exist. and also how could i search 101 and its value here
firstly execute this code then u will understand in a better way
plz help me out from this problem