in reply to if block inside map
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if block inside map
by Eliya (Vicar) on Nov 11, 2011 at 17:42 UTC | |
by AnomalousMonk (Archbishop) on Nov 11, 2011 at 21:14 UTC | |
by Eliya (Vicar) on Nov 11, 2011 at 23:57 UTC | |
|
Re^2: if block inside map
by taiko (Sexton) on Dec 08, 2015 at 11:53 UTC | |
by AnomalousMonk (Archbishop) on Dec 08, 2015 at 16:59 UTC |