September 2014 Archives

Learning Perl 6 - Find in a Large File

Currently I feel it is good to prepare for Christmas.

To read in a larger file, /usr/share/dict/words in my case, I do

my @dictionary = split /\n/ , slurp '/usr/share/dict/words';

That is a cool piece of short code for the task. But - this is slow because I run a regex across a large file, I am told. Also, it is unnecessarily lots of code for the task. Look at that:
my @dictionary := '/usr/share/dict/words'.IO.lines;

Wow.
But also, that was slow a few hou…

About :m)

user-pic I blog about Perl.