use strict; use warnings; use Statistics::LineFit; use Math::Trig; ... my $lineFit = Statistics::LineFit->new(); my @x = map {$_->{col}} @edgeSamples; my @y = map {$_->{row}} @edgeSamples; unless ($lineFit->setData(\@x, \@y)) { print "Invalid data sample for regression; could not calculate skew for $inFile\n"; next; } ... my ($intercept, $slope) = $lineFit->coefficients(); my $angle = atan($slope); $angle *= 180/3.14159265359; ...