Bool

A Boolean value is either True or False. Any value can coerce to a boolean in boolean context. The rules for deciding if a value is true or false depend on the type of the value:

Constructs such as if automatically evaluate their conditions in boolean context. You can force an explicit boolean context by putting a ? in front of an expression. The ! prefix negates the boolean value.

    my $num = 5;

    # implicit boolean context
    if $num { say "True" }

    # explicit boolean context
    my $bool    = ?$num;

    # negated boolean context
    my $not_num = !$num;