It's two negation operators. In scalar context ("!" imposes a scalar context), grep returns the number of matching elements. Negating this twice converts zero to false, and non-zero to true. False is 0 when used as a number. True is 1 when used as a number.
For example,
| Ex. 1 | Ex. 2
-------------------+-------+------
grep returns | 4 | 0
1st negation op | false | true
2nd negation op | true | false
When used as a num | 1 | 0
When used as a str | '1' | ''
|