in reply to Re^2: if block inside map
in thread if block inside map
Other ways:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @x = map $_ > 1, -3 .. 3; dd \@x; " ["", "", "", "", "", 1, 1]
(Note that map $_ > 1 || 0, -3 .. 3 would also work, but map $_ > 1 or 0, -3 .. 3 will not. Can you say why? This is one reason why some Best Practices recommend avoiding the map EXPR, LIST form of map.)c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @x = map { $_ > 1 or 0 } -3 .. 3; dd \@x; " [0, 0, 0, 0, 0, 1, 1]
Give a man a fish: <%-{-{-{-<
|
|---|