in reply to Re: Array seach
in thread Array search

nice examples!, but what does !! do ?

Luca

Replies are listed 'Best First'.
Re^3: Array seach
by ikegami (Patriarch) on Feb 20, 2006 at 14:52 UTC

    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' | ''