perl - Creating an array of arrays for GD::Graph -


all right, i'm trying make array of arrays in perl use gd::graph module. , can't figure out why following not valid array of arrays gd::graph.

my @t = (1, 2, 3, 4); @g = (2, 4, 5, 6); @data = (@t, @g); 

i've tried constructing data below, , still not it.

my @data; push @data, @t; push @data, @g; 

i want keep values in seperate arrays , combine them use gd::graph, because i've found easiest way, if ugly. how go creating valid structure use gd::graph, created on fly?

it complains here.

my $gd = $graph->plot(\@data) or die $graph->error; 

looks @data single dimension array 8 elements.

you can define array of arrays using anonymous array constructor []

my @data = (     [1, 2, 3, 4],     [2, 4, 5, 6] ); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -