Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by Priti24 (Novice)
on Oct 10, 2012 at 07:34 UTC ( #998166=note: print w/ replies, xml ) Need Help??


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..........

Thnks 4 ur reply. bt u didn't reply 4 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 . 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.


Comment on Re^2: trying to implement hash table. and getting lots of difficulties. plz help me out..........
Re^3: trying to implement hash table and getting lots of difficulties
by parv (Priest) 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 (Abbot) 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.....

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998166]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2014-08-21 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls