priyankgandhi has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am working on a project where I have to generate a chart based on values from the log. I am using Chart::Gnuplot to create a chart. But I am having issues. Below is the code for reference. Error: "Not an ARRAY reference at Chart/Gnuplot.pm line 1430."
sub createGraph() { my (@array) = @_; my @values; my @finalResult = {}; foreach my $val (sort { $a <=> $b} @array){ print $val."\n"; @values= split(/\|/, $val); push(@finalResult, [Math::BigFloat->new($values[1]),Math::BigF +loat->new($values[2])]); } my $dataSet = Chart::Gnuplot::DataSet->new( points => \@finalResult, style => "points", title => "$dir" ); $chart->plot2d($dataSet); }

Replies are listed 'Best First'.
Re: Issues with Chart::Gnuplot
by jeanluca (Deacon) on Jul 11, 2009 at 21:20 UTC

      Even better, change it to:

      my @finalResult;

      Perl doesn't need arrays or hashes to be 'set to 0'. Doing so simply adds visual clutter and, in some interesting cases, leads to surprising errors as the OP found!


      True laziness is hard work