DavidSzczesniak
12/11/2017 - 10:31 AM

The Ternary Conditional Operator

Evaluates a conditional expression and evaluates to one of two alternatives.

my $time_suffix = after_noon($time)
                ? 'afternoon'
                : 'morning';

# equivalent to 
my $time_suffix;

if (after_noon(time)) {
  $time_suffix = 'afternoon';
  
} else {
  $time_suffix = 'morning';
}