But trying to read your mind, I suppose you need rather@x = map { if ($_ > 1) { 1 } } (-5 .. 5)
which can be also written with the ternary operator:@x = map { if ($_ > 1) { 1 } else { 0 } } (-5 .. 5)
@x = map { $_ > 1 ? 1 : 0 } (-5 .. 5)
In reply to Re: if block inside map
by choroba
in thread if block inside map
by mhearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |