in reply to Re: 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..........

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Re^2: trying to implement hash table. and getting lots of difficulties. plz help me out..........

Replies are listed 'Best First'.
Re^3: trying to implement hash table and getting lots of difficulties
by parv (Parson) on Oct 10, 2012 at 08:54 UTC
    #!/usr/local/bin/perl use warnings; use strict; use Text::Autoformat 'autoformat'; my $horrid = <<'_INPUT_'; Thnks 4 ur reply. bt u didn't reply 4 my whole question. as i also ask +ed if i search for 47 . then it is giving me index 7 . and at 7 index 37 is gi +ven . so its giving me 37 . bt it should give me that this key is not available +. means how colud i compare my whole keys with key 47. so i can say it is not avaialbe and one thing more if i searched for 201 then there are two keys there then how it will give 201. _INPUT_ for ( $horrid ) { s/\b i \b/I/gxms; s/\b bt \b/but/gxms; s/\b 4 \b/for/gxms; s/\b u \b/you/gxms; s/\b ur \b/your/gxms; s/[ ]([.?!])/$1/gms; } print autoformat( $horrid , { 'squeeze' => 1 , 'justify' => 'left' , 'case' => 'sentence' , 'left' => 0 , 'right' => 78 } ); __END__ Thnks for your reply. But you didn't reply for my whole question. As I + also asked if I search for 47. then it is giving me index 7. and at 7 index + 37 is given. So its giving me 37. but it should give me that this key is not available. Means how colud I compare my whole keys with key 47. so I c +an say it is not avaialbe and one thing more if I searched for 201 then there are two keys there then how it will give 201.
Re^3: trying to implement hash table. and getting lots of difficulties. plz help me out..........
by NetWallah (Canon) on Oct 10, 2012 at 16:53 UTC
    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

      thnk u very much.....