in reply to Returning Statistics::LineFit variables from a sub
use strict; use warnings; use Statistics::LineFit; use Data::Dumper; sub get_hashref { my ($x_ref, $y_ref) = ([1,2,3], [4,5,6]); my $lfit = Statistics::LineFit->new(); $lfit->setData($x_ref, $y_ref); my ($intercept, $slope) = $lfit->coefficients(); my $rSquared = $lfit->rSquared(); my $hashref = { a => $intercept, b => $slope, c => $rSquared }; return $hashref; } # ------ main ------ my $hr = get_hashref(); print Dumper($hr); __END__ $ perl -l 652420.pl $VAR1 = { 'c' => '1', 'a' => '3', 'b' => 1 };
|
|---|