my @numbers = qw /0.12 0.35 1.34/; my $diff = -1; my $di = 0; for (my $i = 1; $i < @numbers; $i ++) { my $d = abs ($numbers [$i] - $numbers [$i - 1]); if ($d > $diff) { $diff = $d; $di = $i; } } if ($di) { print "The diff between $numbers[$di - 1] and $numbers[$di] is $di +ff.\n" }
No time to comment, Amsterdam.pm meets in 10 minutes.
Abigail
In reply to Re: extracting corresponding values from another array
by Abigail-II
in thread extracting corresponding values from another array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |