?: is the conditional operator. See perlop for documentation. In short,
cond ? then_expr : else_expr
is similar to
if (cond) { then_expr } else { else_expr }
except it can be used inside another expression. It returns the value of then_expr or else_expr as appropriate. That means
my $count = $row[0] ? $row[0] : 0;
is short for
my $count;
if ($row[0]) {
$count = $row[0];
} else {
$count = 0;
}
Update:
It could also have been written as
my $count = $row[0] || 0;
It seems to me it's trying to avoid assigning undef to $count, using zero instead when the situation occurs.
|