http://qs321.pair.com?node_id=11121823


in reply to Re^3: regex, find words that occur more than once.
in thread regex, find words that occur more than once.

Hopefully I properly qualified my comments since I tried to offer them as food for thought rather than some prescriptive set of requirements.

The pre-increment is a good suggestion, and aligns with a verb-object syntax nicely. I need to break that muscle memory.

The subject of the post agrees with your interpretation of the hash, but the usage runs counter. As soon as the goal becomes "How many times are words repeated?" the approach should have an accurate count in whatever stash you are using, as close to data as possible. Obviously the best answer is what you gave in Re: regex, find words that occur more than once., but subject to a homework-like requirement of use a regex a defined-or assignment keeps the store honest while still being reasonably succinct (and doesn't net add any lines). I'm not fundamentally opposed to communicating that the keys are the important thing, but especially when people are starting out, having the hash named after the property you are measuring (e.g., %count, %seen, %formatted) avoids %words, %others, %words2 anti-patterns.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.