|
|
| No such thing as a small change | |
| PerlMonks |
Comment on |
| ( #3333=superdoc: print w/ replies, xml ) | Need Help?? |
|
you could use the conditional operator aka "ternary operator" :
my @cell_contents = map { $_ ? 1 : 0 } @$array_ref[3..10]; another idea is to use doubled negation "!!" and to map the empty string (false) to 0. my @cell_contents = map { 0 + !!$_ } @$array_ref[3..10]; but I don't think this conciseness justifies the loss of readability.¹
Cheers Rolf ¹) well if you really need 0 for false. In reply to Re: A more concise way to map the contents of an array.
by LanX
|
|