DavidSzczesniak
12/7/2017 - 11:50 AM

Force numeric, string or boolean context

This can be useful in rare situations when you may not be able to use the appropriate operator to enforce value context,

my $numeric_x = 0 + $x; # forces numeric context with the + 0 
my $stringy_x = '' . $x; # forces string context by catting the variable with an empty string
my $boolean_x = !!$x; # forces boolean context by doubling the negation operator