I know how to easily split a string and push the entries onto an array, but in this case I need to decrement them all by one as well. I could do:
my @valueArray = ();
my $values = "1,7,30";
push @valueArray, split(/,/, $values);
for (my $i = 0; $i < scalar(@valueArray); $i++) {
$valueArray[$i]--;
}
but this beeing perl it seems like there should be a shorter way to do that between the split and push. Is there, or should I stop golfing and just go for the for loop?
How about this?
You don’t need to decrement here; in fact, rarely
mapshould be used when its inner block updates the values of original array elements – and vice versa. )