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

hi there, i got following code:
$grey = $gd->colorAllocate(220,220,220); @list = $dia->get_hotspot(1,$point); $gd->dashedLine($list[1],25,$list[1],$list[2],$grey);
tested on my winnt-pc it works fine. but when i run it on my solaris 8 machine i always got this error message:
Can't use an undefined value as an ARRAY reference at /usr/local/lib/p +erl5/site_perl/5.6.1/GD/Graph/axestype.pm line 366.
how can i approach the reason for this? thx mtm

Replies are listed 'Best First'.
Re: GD & GD::Graph
by Mr. Muskrat (Canon) on Nov 06, 2002 at 16:15 UTC

    Okay, here is the sub that is causing the problem.

    sub get_hotspot { my $self = shift; my $ds = shift; # Which data set my $np = shift; # Which data point? if (defined $np && defined $ds) { return @{$self->{_hotspots}->[$ds]->[$np]}; } elsif (defined $ds) { return @{$self->{_hotspots}->[$ds]}; } else { return @{$self->{_hotspots}}; } }
    Off the top of my head, I'd say that you are pointing to a non-existant data set or point.
    Make sure that you really want to put the hotspot on the second data set.
    To put the hotspot on the first data set try this:
    @list = $dia->get_hotspot(0,$point);
    Also check to see if $point is a valid point in the chosen data set.

      hmm,
      i'll try to use the first data set.
      but the first data set isn't really a data set, it's the labels for the x-axis.

      $point is a valid point, it is validated in the script itself.

      for better understanding:
      i'm reading a list of telegramms and then create a chart to show the ammount of telegramms/sec.
      the datasets all have 1440 elements (as a day has minutes).
      for the minutes without any telegram, i insert a element with the value 0. (so after the list was read, i stretch the dataset, so that there is an element for every minute) the $point is within this range (0-1440)...

      on both systems (solaris and winnt) this problem causing sub looks alike.
      so it is not really the sub, i think. it's more likely some stupid solaris environment variable, that interferes with my perlscript...

      greetz mtm
        hmm, well, the first dataset won't work, too.
        i think i'll have to write some debugprints into the sub. I not really ever wanted to edit a pm...
Re: GD & GD::Graph
by Mr. Muskrat (Canon) on Nov 06, 2002 at 15:53 UTC

    Do you still get that error when you remove those three lines of code?

      no,

      the error occurs in this line: @list = $dia->get_hotspot(1,$point); that's the point, where i call the get_hotspot method from the gd::graph module.
      i need this hotspot to draw a timeline into my chart. well of course, if i ommitt this line, the next line will produce a new error, 'cause @list won't be defined then...

      so the error seems to be in the part of the gd::graph module, where the get_hotspot method is defined.(here called axestype.pm) but the sourcecode (comparing the module from winnt with solaris) is the same...