http://qs321.pair.com?node_id=1214667

writch has asked for the wisdom of the Perl Monks concerning the following question:

I have a loop that calculates the difference between a variable in an array to the next element in the array. I'm currently using a pretty standard manner of doing this, namely

for (my $i=0;$i<@a;++$i){ $b[$i] = $a[$i] - $a[$i+1]; }

I wondered if there was any way to address the "$_ + 1" thought in a map statement. I've been looking for any examples, but I don't find them. Obviously this isn't it, but that's the thought at least.

@b = map{$_ - $_+1}, @a;