And I am guessing that I would not want to use the sorted version I have listed above for performance reasons
With a trie it doesn't matter. Any (list|of|fixed|words), no matter how long or whether sorted or not will be pre-compiled into a trie. The only thing you should do is deduplicate them. To give you some idea of the performance difference, taking the pattern at the end of your posting
and doing a repeated failed match against a long string:
my $r = qr/(?:u|uau|uauau|
....
ufududufubudufufudufubudufu)/x;
my $s = "a" x 1000000;
$s =~ $r for 1..10;
On my laptop, this takes 27s on 5.8.9 and 0.024s on 5.10.0 and later.
perl 5.10.0 was released about 8 years ago. If you're going to do lots of matching against big word lists it would pay to upgrade to something newer than 5.8.x.
Dave. |