The first time you see the line:
- $seen{"abc\n"} doesn't exist, so it's effectively undef.
- $seen{"abc\n"}++ increments $seen{"abc\n"} to 1 and returns the original value (undef).
- "!" negates the value returned by the postincrement (undef), returning true.
- The "if" body is entered.
The second (or third, or fourth) time you see the line:
- $seen{"abc\n"} was previously set to 1 (or 2, or 3).
- $seen{"abc\n"}++ increments $seen{"abc\n"} to 2 (or 3, or 4) and returns the original value (1, or 2, or 3).
- "!" negates the value returned by the postincrement (1, or 2 or 3), returning false.
- The "if" body is not entered.
It's just one of those useful patterns one memorises.