in reply to What does "! !" do?
It's effectively a "cast to boolean" operation.
Consider you have a variable $x which might contain a string, or might contain a number - you're not quite sure. If you want to force it to be treated as a string, you do something like this:
say ($x . ""); # concatenate an empty string to it
Or if you want to force it to be treated as a number:
say ($x + 0); # add zero to it
!! does the same for forcing things to be a "boolean". Perl doesn't have real booleans (though there are CPAN modules for that) so in this case uses the empty string to represent false, and the number 1 to represent true.
How does it work? A single ! is just a "not" operation. Two not operations cancel each other out truth-wise, but still act to cast the value to boolean.
|
|---|