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;
Here are some comments on the mop-redux regarding situations in which Perl OO (code) is thought to newcomers or to outsiders. Such situations could be explaining code to an non-Perl colleague at work for a holiday substitution or a Perl class in high school.
With great interest I read When "unsafety" is a Good Thing and brood over Gabor's comment regarding "inconvenience vs. danger".
In my job, I have done a fair amount of coding these days. Mostly smaller tasks, you know, the sort of problem you just not so easily solve with Excel. I did some gardening, so to speak..
I just wanted to say that if you stumble with a regex try Regexp::Debugger.
It saved me twice today facing problems too silly to describe here. :-)
Here is how I proceeded:
- write regex and see it not doing what I want
- think, rewrite, think again, rising anger
- insert Regexp::Debugger the line before regex
- play the regex, facepalm (in a positive way)
I now think about writing more complicated regexes. I want to enjoy the debugger even longer. ;-)