Fundamentals3 / 5
Up next

Conditionals

use strict;
use warnings;
use feature 'say';

my $n = 7;
# if / else
if ($n % 2 == 0) {
    say "even";
} else {
    say "odd";
}

# unless is "if not"
unless ($n > 100) {
    say "small";
}

# the ?: ternary picks one of two values
my $sign = $n >= 0 ? "positive" : "negative";
say $sign;
What you're solving

if/else, unless, the ternary