codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Finding data in hash  Enniob at 01:12 on Tuesday, November 18, 2008
 

I have an array with over 100 terms (example: house, dog,...)
I also have another array with 5 text (example: the dog lives in the house) Each place in the array has some text simillar to the example.

Now I'm trying to get all the values from the array with 100 terms, and look inside the other array with the text to see how many text has the terms. since the array has only 5 text the maximum value for the terms is 5. So 1 term can be in 5 text or 4 text or 3 text or 2 text or 1 text or 0 text.

here is the code that I have that is trying to do this. But the problem is that I alway get 5.

[code]
for ($counter = 0; $counter <= $#terms; $counter++){
$nDocs = 0;
for ($count = 0; $count <= $#doc; $count++){
@docTemp = split(/\s+/, $doc[$count]);
###################################
# STORE THE DOCUMENTS INTO A HASH #
###################################
for my $word (@docTemp){
$docHash{$word}++;
}

if (exists $docHash{$terms[$counter]}){
$nDocs++;
}
}
print $terms[$counter], " ", $nDocs, "\n";
}
[/code]

  Re: Finding data in hash  hermanningjaldsson at 21:03 on Thursday, November 27, 2008
 

Run that code with the ptkdb debugger, that should help you narrow the problem down.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009