http://www.perlmonks.org?node_id=1027483


in reply to Re^3: Longest String Matching
in thread Longest String Matching

Adding the empty string to the lexikon allows the following shortening:

$lookup{''} = 1; substr($word, 0, 1) = "" while !exists $lookup{$word};