in reply to Perl array access in a for loop

Actually it's just:

$data[$i] - $data[$i - 1]

What though have you actually tried? What error message or behaviour is confusing you? Can you put together a sample something like the following code that demonstrates the problem you have?

use strict; use warnings; my @table = (1, 2, 4, 6, 10); my @diffs; for my $index (0 .. $#table - 1) { $diffs[$index] = $table[$index + 1] - $table[$index]; } print "@diffs\n";

True laziness is hard work