http://www.perlmonks.org?node_id=1010918


in reply to A more concise way to map the contents of an array.

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.