in reply to Re^3: count number of overlapping words in a document
in thread count number of overlapping words in a document
Thank you very much. This 'education' will certainly help me in the future, and I made the adjustments you've recommended. The code is now clear and I understand how the code is set up. The last task was actually very simple in the end, I just did not realize I could use the regex for this task as well
my $totalwords; $totalwords ++ while $text =~ m{\b[A-Za-z]+\b}g;
I do have one small issue left to be resolved. After adding the do-loop to count the total number of hits, I get the following error: Use of unitialized value $1 in hash element. The code will function, but adds one empty 'word' to the final result with the count of one (thus the code always has a bias of +1) (and I get many errors when I use it for multiple files). Any quick fix available?
Update: solved the problem through a foreach loop
|
|---|