Binary search to find words in a list: Perl tutorial
Given a dictionary, say one of the frequent words lists of the University of Leipzig, given a series of words: How can you check which ones belong to the list ?
Another option would be to use the operator available since Perl 5.10: :::perl if ($word ~~ @list) {…} But this gets very slow if the size of the list increases. I wrote a naive implementation of the binary search algorithm in Perl that I would like to share. It is not that fast though. Basic but it works.
First of all the wordlist gets read:
my $dict = 'leipzig10000';
open (DICTIONARY, $dict …