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

Greetings,

I'm trying to port data (text delimited file) into Perl and using that data to replace the multi-dimensional array used in the GD::Graph module. I'm trying to place the data from a database to dynamically draw up a line chart.

The examples shown on the module provide only hard coded data in the script. I guess I would have to say that I'm not used to dealing with placing variables into multi-dimensional arrays.

Has anyone seen an example of this or sample source on how to go about this?


tia, gus

Replies are listed 'Best First'.
Re: Flat File Database & GD::Graph
by dws (Chancellor) on Mar 11, 2002 at 21:27 UTC
    I'm trying to port data (text delimited file) into Perl and using that data to replace the multi-dimensional array used in the GD::Graph module.

    I assume that by "replace" you mean to use data loaded dynamically, rather than statically.

    Something along the lines of the following fragment should do. It assumes three comma-delimited numbers per row of data.

    while ( <DATA> ) { chomp; my($a,$b,$c) = split; push @{$data[0]}, $a; push @{$data[1]}, $b; push @{$data[2]}, $c; } open(IMG, ">chart.png") or die("chart.png: $!"); binmode(IMG); print IMG $graph->plot(\@data); close(IMG);