in reply to Re^3: Explain the code
in thread Explain the code

The ++ is evaluated for every item in @a, grep only checks its return value and picks (or not picks) the element based on that value.