This !! idiom is mentioned in the recently released Modern Perl book in an excellent section on Numeric, String, and Boolean Context on page eight. After advising you to use the proper operator for the type of context you want, it concludes with:
In rare circumstances, you may need to force an explicit context where no appropriately typed operator exists. To force a numeric context, add zero to a variable. To force a string context, concatenate a variable with the empty string. To force a boolean context, double the negation operator:my $numeric_x = 0 + $x; # forces numeric context my $stringy_x = '' . $x; # forces string context my $boolean_x = !!$x; # forces boolean context
In reply to Re: Anybody use !!
by eyepopslikeamosquito
in thread Anybody use !!
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |