in reply to explain use of increment operator in grep
The increment is '++$temp{$_}', which means that the hash value is incremented before the "less than 2" test is performed (as opposed to '$temp{$_}++', which would increment after the test is done).
So, the first time a given string is encounted in @list, the resulting hash value satisfies the condition (incremented, it is less than 2). Each time the given string is encountered again, the increment puts the hash value above 1, so that the "less than 2" condition will fail, and grep will exclude that list item from the set that it returns.
|
|---|