(It is not optimized!)#!/usr/local/perl -w use strict; use warnings; my @file = ('0.13','0.14','0.14'); my $diff = 0; my @diffVal; for (my $i=1 ; $i< scalar(@file) ; $i++){ if ($diff < abs($file[$i-1]-$file[$i])){ $diff = abs($file[$i-1]-$file[$i]); $diffVal[0] = $file[$i-1]; $diffVal[1] = $file[$i]; } } print "Difference between $diffVal[0] and $diffVal[1] is $diff\n" if ( +defined($diffVal[1]));
In reply to Re: Comparing numbers
by Chief of Chaos
in thread Comparing numbers
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |