in reply to getting problem to free an array values..

Have you tried it like this:
my $dataSet = Chart::Gnuplot::DataSet->new( points => [ @finalresult ], ### pass a ref to anonymous array, n +ot ref to global array style => "linespoints", title => "points" );
When you do that, does it work better?

(updated comment in code to clarify)