http://www.perlmonks.org?node_id=998260


in reply to Re^2: trying to implement hash table. and getting lots of difficulties. plz help me out..........
in thread trying to implement hash table. and getting lots of difficulties. plz help me out..........

If you want to fail the search when the item is not found, you need to add the following line before the final "print"
die "$k was not found (slot $h)" unless grep {$k==$_} keys (%{$buckets +[$h][0]});
There are actually 3 keys in the "201" slot.
If you run the code I posted, it will show all three.
If you wanted to show only the matched key, you can use a grep statement , very similar to the one above.

             I hope life isn't a big joke, because I don't get it.
                   -SNL

  • Comment on Re^3: trying to implement hash table. and getting lots of difficulties. plz help me out..........
  • Download Code

Replies are listed 'Best First'.
Re^4: trying to implement hash table. and getting lots of difficulties. plz help me out..........
by Priti24 (Novice) on Oct 11, 2012 at 06:08 UTC
    thnk u very much.....