This snippet as written will set each index in the range to true, leaving all others as undef, or false.
my @stuff; my $vals = "1,3-5,7"; $vals =~ s/(\d+)-(\d+)/join ',', $1..$2/eg; # If you need to convert to 0-based ... $vals =~ s/(\d+)/$1 - 1/eg; my $numIndices = scalar split ',', $vals; eval "\@stuff[$vals] = (1) x $numIndices;";
|
|---|